1. Floating point arithmetic not producing exact results in Java stackoverflow.comI need to do some floating point arithmetic in Java as shown in the code below:
|
2. Floating point arithmetic coderanch.comHi everyone, This line: System.out.println((0.1+0.7)*10); outputs 7.999999999999999 This is due to how floating point numbers are stored (IEEE 754). When writing a code, sometimes it behaves in an intended way, sometimes it doesn't (like the one above). Is there a way to "predict" when the code is ok and when isn't ? Are there any tips to be aware of to ... |
3. Floating point arithmetic forums.oracle.com |
4. Float arithmetic forums.oracle.comHi all Just looking for some help with some arithmetic. i have an array of floats and i wish to multiply them all by 2 and subtract 1 but i seem to be having some problems. the first float is 0.4 but when i *2 -1 i end up with -0.19999999 instead of -0.2 but im not sure why can anyone ... |
5. Floating point arithmetic forums.oracle.comNo. Using BigDecimal just because you don't understand how floating-point numbers work would be... um... short-sighted. And it wouldn't help, either. As soon as you divide 1 by 3 then you have to know how decimal numbers work, which is essentially the same problem. Edit: I forgot the forum hasn't been automated to provide the mandatory link for people who ask ... |