ID:105940
 
Not Feasible
Applies to:DM Language
Status: Not Feasible

Implementing this feature is not possible now or in the foreseeable future
var/X=16777215
world<<X

// Output: 1.67772e+007


This may be one of the most annoying features I've ever encountered. Frankly I believe it should just be completely disabled, but having some sort of flag in DM would suffice, I suppose.
I agree.

I have not come across a BYOND game that needed scientific notation.
You can use num2text() when displaying it. Considering numbers over 999,999 become ridiculously inaccurate, its understandable. That's the bigger issue IMO, can't even properly compute YYYYMMDD dates in a single variable.
I agree, this should be disabled.
Falacy wrote:
You can use num2text() when displaying it. Considering numbers over 999,999 become ridiculously inaccurate, its understandable. That's the bigger issue IMO, can't even properly compute YYYYMMDD dates in a single variable.

It would be better to use num2text to display it as scientific notation with the normal way of expressing it being default. Secondly, the frell do you mean by "ridiculously inaccurate?" BYOND deals with 24-bit floats. If we had a real int type, more data could be held, but the data type used can handle far more than 999,999.
Around 17 million you can no longer increment numbers by 1. I believe numbers above that also lose precision, but I'm not 100% sure. I actually thought it happened a lot lower than that, but my tests just now have shown otherwise.
Not that I'm against this suggestion. I think its somewhat pointless to have scientific notation at all, and especially as the default. I think it would be more more effective to have built-in systems which format numbers using commas, if anything.
The number you're thinking of is 16777215, or 2^24 - 1. BYOND stores numbers as 24-bit floats, so that's the reason. In most languages you can specify which data type to use for numbers (signed/unsigned int short long float double) but BYOND doesn't give us that ability.
I'll have to agree it's a pretty ridiculous feature.

p.s.
The number you're thinking of is 16777215, or 2^24 - 1. BYOND stores numbers as 24-bit floats, so that's the reason. In most languages you can specify which data type to use for numbers (signed/unsigned int short long float double) but BYOND doesn't give us that ability.

I had that misconception too but was corrected. That's wrong, actually.
Nope Toadfish, Airjoe is correct about the floating point numbers, although it's not phrased entirely right. It's closer to correct to say the numbers are 32-bit floats, but they only carry a 23-bit mantissa and therefore only 24 bits of accuracy. They can however accurately represent any integer from -2^24 to 2^24 inclusively.

I suspect this feature doesn't have much for legs since adding another flag to the language would be the sort of complicating minor feature Tom usually doesn't care for, but for now I'll move this to Needs Discussion.
Lummox JR: While I appreciate the insight into the backend of the system, do you have any comment for the feature itself?
You missed my edit by just seconds I think. This is feasible but it's probably not the kind of thing that will be implemented.
So rather than a flag, why not change the default behavior?
Airjoe wrote:
So rather than a flag, why not change the default behavior?

Chance of breaking existing games. Most I can think of would be graphical systems designed to display no more than 6 characters.
How would disabling the scientific notation break "graphical systems designed to display no more than 6 characters?"

Look at my example in the original post. It takes an eight digit number and turns it into a twelve character string. Scientific notation doesn't always save space.

And even still, if your system has a limitation, you should be catching exceptions, not depending on behind the scenes magic to save you.
Airjoe wrote:
And even still, if your system has a limitation, you should be catching exceptions, not depending on behind the scenes magic to save you.

If you're going with that stance, then you should be overriding this yourself to begin with. It is a pretty simple process.
Changing the default is not an option. It would modify the behavior of existing games, and it's also not clear where we'd draw the line. At some point with very large numbers we'd have to still switch to scientific notation or you could have ridiculously long numbers. This would also obscure the fact that we're using floating point and further confuse people who run into the limitations of the format without realizing what's going on.
Lummox JR wrote:
...and it's also not clear where we'd draw the line...

If the current system loses precision at 16,777,215, then that seems like a more sensible point than the current 1,000,000. Just throwing that out there, not that I think a change would be possible at this point.