1. ## Math Issues

Umm... Hi.

Whenever...

33.3 + 33.3 + 33.3 = 99.89999

or

33.3 * 3 = 99.8999

Why doesn't it equal 99.9?

-Berserker 2. umm..

and

cannot help

Why not post code? 3. Because floating point numbers can not respresent every number accurately. However 99.9 does = 99.89999999999999999999999999999999999999999999999 9999999999(to infinity) 4. Sorry Calculating a triangle's perimeter.

void perimeter(void)
{

float perimeter, a, b, c;

printf("Please input side A > ");
scanf("%f", &a);
printf("Please input side B > ");
scanf("%f", &b);
printf("Please input side C > ");
scanf("%f", &c);
perimeter = a + b + c;
printf("\nThe final solution is... > %.5f\n\n", perimeter);
} 5. Originally Posted by Thantos
Because floating point numbers can not respresent every number accurately. However 99.9 does = 99.89999999999999999999999999999999999999999999999 9999999999(to infinity)
Is there any way I can accurately depcit all numbers? 6. Nope. Due to memory limitations and per fact that some numbers just never end it's impossible to accurately store all numbers. What you have to do is decide how close is close enough.

Edit: you can also try using double instead of float but I don't know how much difference it'll make in this case. 7. Originally Posted by Thantos
Nope. Due to memory limitations and per fact that some numbers just never end it's impossible to accurately store all numbers. What you have to do is decide how close is close enough.

Edit: you can also try using double instead of float but I don't know how much difference it'll make in this case.
Perhaps that is what I don't understand.
To me, 3.33 + 3.33 + 3.33 should equal 99.9. Not 99.8999...
I know it can't store all numbers, but it should accurately depict the numbers displayed.
It screws up Pi too, but that is more understandable.
Oh well, I guess I'll never understand it.
Thanks anyway.

PS: Double did the same as float. 8. Here is an explanation of fixed-point math, which may also help explain what flaoting point numbers are doing to confuse you.

http://www.wwnet.net/~stevelim/fixed.html 9. You could also have a look at arbitrary-precision math libraries, like http://www.tc.umn.edu/~ringx004/mapm-main.html 10. Popular pages Recent additions 