Questions tagged [floating-accuracy]

Concerning the accuracy of operations performed on floating point numbers.

Floating point numbers (typically meaning the IEEE standard) are inherently inexact and errors can compound, leading to edge cases in some decision processes, or numerical instability in certain algorithms.

Here is a mathematical treatment of the main problems.

1358 questions
-4
votes
1 answer

C: How to perform accurate floating-point operations?

I am well aware that 0.1+0.2 != 0.3 because of precision errors. However I need it to be equal to 0.3. My solution would be to : Declare an add function that returns the correct double. Inside this function, add the two numbers then round to the…
Zezombye
  • 321
  • 4
  • 16
-4
votes
1 answer

Float not being converted correctly

I am working on a program that will convert from dollars to cents. I take in user input as a float using a predefined function then i try to multiply this float by 100 but it gives me an incorrect value. Heres the code: printf("Change in dollars:…
Farid
  • 19
  • 1
  • 4
-4
votes
2 answers

Fortran 1.0/0.2=4?

The code is below: program error implicit none real :: l,h integer :: r l=1.0 h=0.2 r=l/h print*,r end program error The problem is that the answer is 4. When I explicitly divide 1.0 by 0.2, the answer is 5, but when I use symbols, it is 4. In…
-4
votes
5 answers

Why the result of '0.3 * 3' is 0.89999999999999 in scala language?

Why the result of multiplication 0.3 and 3 is 0.89999999999999 in Scala?
Kyokook Hwang
  • 2,682
  • 21
  • 36
-5
votes
1 answer

accuracy of sinl and cosl function in c++

I want an accuracy of about 0.000001. typedef struct p { long double x; long double y; }point; point rotate_point(long double cx,long double cy,long double angle,point p) //pivot then angle then point to rotate { //…
-5
votes
2 answers

How to get the answer to exact bits using double in android

I have made a Calculator app on android but whenever I do some multiplication of the kind: 23.3 x 3.3 The answer I get is something like: 76.988999999999 Now please tell me how to resolve this conflict with this app. The answer should be…
-7
votes
1 answer

Why dose cos(90) not equal zero?

I understand that cos(); in c++ uses radians right.. and you can get radians with.. (angle * PI ) / 180; So why does float value = cos( (90 * PI / 180 ); // == 6.1 etc... and not 0? If I use the scientific calculator in windows for cos(90) I…
aJynks
  • 677
  • 2
  • 14
  • 27
1 2 3
90
91