Is it safe? Very small numbers.
Monkey Forums/Monkey Programming/Is it safe? Very small numbers.
| ||
duplicate |
| ||
Hello everyone! Is it safe to use numbers like 1e-100? I use them to store big numbers in my game. For example if I have monster's health about 1,000,000,000 I use float * X instead. JSON seem to save numbers like this without any problems. It seems okay for now. Will it bite me later when I reach some enormous numbers? Thanks! Alex |
| ||
Look up floating point roundoff error. I wouldn't recommend using very small numbers because you'll have limited precision. On some targets, precision is as bad as 5-6 decimal places. |
| ||
Thank you Nobuyuki. Yes, I already had some precision issue. However, it seems that the precision is as bad as 5-6 decimal places *after* the decimal I use. For example if I use 1e-30, it can become 9.99999e-30 or 1.000001e-30. So as I use the rounder function, I add 1e-30 * .1 and everything seems good so far. Will test it deeply and post here! |