Re: Should %d round?

new topic     » goto parent     » topic index » view thread      » older message » newer message
Vinoba said...

The logic:

In ASCII, ANSI, UNICODE, the characters 0-9 and the decimal point are characters.

Unlike most languages, Euphoria has chosen the route of recognizing literals and numeric characters as one, at least to start with and only later recognize the special characters as worthy of mathematical manipulations.

If we take "3.99999" as a string of literals only, we can safely say we want 1 character "3" or THREE characters "3.9".

However, the moment we recognize the decimal point as something special and meaningful mathematically, we are required to recognize the whole string as a number which needs to be interpreted and portrayed rationally in its full or abbreviated form.

Your interpretation is one rational way to do things. However, it's not the way we do things, or the way most do things. You are making assumptions that are not valid in this case, and are certainly not required.

Vinoba said...

Another argument for a more rational and practical approach is the fact of calculations occurring in hex and these are represented in decimal format.

It is conceivable that some calculations may end up as 3.99999 when actually the number might best be represented as 3.99998 or 4.00000. Therefore, in portraying the result of the previous hex calculations as 3.99999 is at best an approximation. Somebody might argue that it was 3.99999482397, but that it only reinforces my argument that very often the literal "3.99999" has a value not quite 3.99999.

Yes, once again, you make a case for careful display of your results. No one has argued against this (although the calculations are done in binary, not "hex"). If anything, you reinforce the argument that you probably shouldn't be using %d for this sort of data.

Vinoba said...

Hence the need for a rational mathematically sound and practical approach.

How lucky for us that we already have one!

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu