Geogebra afrunder tal med for mange decimaler.

Filip Binderup shared this problem 8 months ago
Not a Problem

Danish:

Hvis et tal har mere end 9 decimaler afrunder den til nærmeste 8. decimal. dette vil sige at 1-(10^(-9)) vil den afrunde til 1, dette vil sige at hvis jeg har brug for at runde 1-(10^(-12)) ned, ved hjælp af floor() kommandoen, vil jeg stadig få 1, selvom det rigtige svar er 0.

English:

If a number has more than 9 decimals, it will automatically be rounded to the nearest 8th decimal. This meas that 1-(10^(-9)) will be rounded to 1. I need to round 1-(10^(-12)) down using the floor() command, I would get 1 when the value I should get, and that I need, is actually 0.

Comments (4)

photo
1

You mean with a==b? Yes, that's deliberate


Please post your .ggb file so we can help

photo
1

The problem is that floor(1-10^(-9))=1 when it should be 0

Here's the ggb file, but beware, it's in danish.

it's a unit converter, where you can turn a number into either binary, hexadecimal and more, if you try to convert a number with more than 9 digits, the code breaks and more often than not it'll give back an incorrect answer.

Files: here.ggb
photo
1

Well, you can try a trick like floor(1-x*1000000)/1000000 but you will always run into limitations at some point with floating point numbers. You might have more luck using the CAS which keeps numbers exact


https://docs.oracle.com/cd/...

photo
© 2021 International GeoGebra Institute