ID:1700110
 
Not a bug
BYOND Version:507
Operating System:Windows 7 Home Premium 64-bit
Web Browser:Chrome 37.0.2062.124
Applies to:Dream Seeker
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
Addition appears to become increasingly inaccurate as the numbers being added get very large.



Code Snippet (if applicable) to Reproduce Problem:
Compile & Run this in dream maker. Output however you like.
num2text(16777215 + 16777216, 8)

Expected Results:
Should output 33554431

Actual Results:
Actually outputs 33554432

Does the problem occur every time?
It occurs every time. Larger numbers than these will give more and more inaccurate results.

When does the problem NOT occur?
When the numbers are small but I'm not sure at what exact point the error will start creeping in.
There's a reason behind this.
BYOND holds numbers in 32-bit floats. 1 bit is used for sign, and 7 bits are used for exponent, leaving 24 bits for actual number data. 24 bit numbers can only go as high as 16777215 before precision begins to falter.

Floats are good for making calculations of numbers that can be very big or small, but when it comes to the number of significant digits, they can be a bit lacking.
In response to Mr_Goober
Right, thanks. True true. Probably good to have this here in case people notice the same thing.

In say Java I would start using a long but of course we're tied to BYOND's best guess at what we need. Fair enough. Always interesting to bump against a limit.
From what I heard, changing the internal data type to long would prove to be a much harder task than it seemed to be. If you need numbers with more precision, you can find a library which handles numbers as digits in lists, such as the BigNum library.

On a related note, binary operations will only work with 16 bits. You could make a library which makes use of this and hold the data as 16-bit numbers in a list. At the same time though, parsing it to text probably would be a lot more annoying than using 0-9 for each list cell.

Good to know you're working hard! When pressed with limitations, we all must find ways to work around them.
Nadrew resolved issue (Not a bug)