Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EOL Real number addition overflow
EOL Real number addition overflow [message #1803678] Wed, 06 March 2019 16:12 Go to next message
Bas Har is currently offline Bas HarFriend
Messages: 18
Registered: May 2017
Junior Member
I am trying to perform an addition on real number in an EOL script. Some of the calculations keep overflowing.
Does there exist an approach to handle this overflow?

Example:
3.0E-8 + 4.0E-7
The result should be 4.3e-7
But EOL returns 4.2999999999999996E-7

Appreciate any assistance.
Thank you.
Re: EOL Real number addition overflow [message #1803688 is a reply to message #1803678] Wed, 06 March 2019 19:03 Go to previous message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

We are using standard Java (IEEE 754) floats / doubles, no special magic :-). Remember that IEEE 754 floating point numbers are always approximate: some numbers are not directly representable. If you need something with arbitrary precision, BigDecimal may be a better choice.

Here is a quick StackOverflow article which discusses the issue:

https://stackoverflow.com/questions/3413448/double-vs-bigdecimal
Previous Topic:Problem compiling RCP using tycho and epsilon
Next Topic:Need help getting started with EUnit
Goto Forum:
  


Current Time: Thu Apr 25 17:14:15 GMT 2024

Powered by FUDForum. Page generated in 0.03255 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top