1
QB64 Discussion / Maths accuracy
« on: May 26, 2021, 07:18:59 am »
Hi all
Trying to do this (although with figures from an array rather than directly programmed numbers - getting the same result):
I should get 5617.61 but for some reason I'm getting 5617.609.
Why and how can I be sure to get the exact result I need? Should I use a different type of number?
I'm using type ! because the numbers could possibly go up to 86400 (number of seconds in 24 hours) and I need 2 decimal point accuracy (as that's what my timing system outputs).
Is there a better option, or alternatively, how can I make sure the answer always comes back rounded up to 5617.61?
Thanks
Trying to do this (although with figures from an array rather than directly programmed numbers - getting the same result):
Code: QB64: [Select]
- finishseconds! = 39818.38
- startseconds! = 34200.77
- PRINT finishseconds! - startseconds!
I should get 5617.61 but for some reason I'm getting 5617.609.
Why and how can I be sure to get the exact result I need? Should I use a different type of number?
I'm using type ! because the numbers could possibly go up to 86400 (number of seconds in 24 hours) and I need 2 decimal point accuracy (as that's what my timing system outputs).
Is there a better option, or alternatively, how can I make sure the answer always comes back rounded up to 5617.61?
Thanks