Is it possible to get an "exact" value? - page 5

 
WePlexus:
Yes, and the calculator says 0.09*5=0.45. :)

just needs to be normalized:

//double d=0.019999999999999999;
double d=NormalizeDouble(0.09*5,2);
double e=(int)(d*100)/100.0;
Print("e=",e);
 
abolk:

well, sanyok, you're a liar.

My function:

=0.44.
I didn't check yours.)
 
abolk:

normalisation just needs to be done:

also an option )))

and what's up with the number? )))

0.01999999999999999999
 
sanyooooook:

also an option )))

and what's up with the number? )))

this is the maximum number with which normalisation works:

double d=NormalizeDouble(0.01999999,18);
double e=(int)(d*100)/100.0;
Print("e=",e);

if you take one more 9, it's normalized to 0.02.

 
abolk:

is the maximum number with which normalisation takes place:

If you take one more 9, it's normalized to 0.02.
don't cut it off.)
 
sanyooooook:
don't truncate the number.)
whatever -- NormalizeDouble() 's accuracy format is 0-8
 
abolk:
so sideways -- the format of accuracy in NormalizeDouble() -- 0-8
so it's already sideways))
 
sanyooooook:
so that's it, it's all the same))

we're already getting to the "heart of the problem" -- that's why "already"

first the decomposition of the problem -- then the composition of the problem

or are there still some loose ends?

 
abolk:

we're already getting to the "heart of the problem" -- that's why "already"

first the decomposition of the problem -- then the composition of the problem

or are there still some unexplained points?

yes )

how to use the same function (say, the one you wrote) to truncate any input number to the right number of digits:

even if it's this:

0.01999999999999999999

or this:

0.09*5
 
sanyooooook:

yes )

how to truncate any input number to the right number of digits using the same function:

even if it's this:

or this:

To solve this problem, 0.09*5 has to be =0.45, not =0.44999999999999999

and if there is no such a thing, then the problem is unsolvable

Reason: