Paul Lutus wrote:
> Robert Klemme wrote:
> 
> / ...
> 
>>> BTW, the behavior goes beyond integers and floats. It also applies to
>>> extended-precision numerical types.
>> And as far as I know it's even an IEEE standard.
> 
> I think that's true also, but certainly type promotion is what people expect
> to happen.

In this case I lean on the standard's side: numerics are just too basic 
and fundamental to let implementers of languages do what they like.  I 
know a case where a legacy system doing static calculus was replaced by 
a new system on a totally different OS platform.  Data was migrated and 
afterwards people complained that the new system was doing the match 
wrong.  It turned out that it was the *old* system that actually had the 
math wrong.  They were lucky that in years no building crashed because 
of this...

>> Programming systems 
>> better comply with it in order to make results comparable and
>> interchangeable.
> 
> There's a can of worms. It turns out the behavior of the different languages
> WRT conversion from and to base ten leads to some borderline failures if
> the textual forms are transferred between environments.

I am sure, conversion is yet another standard. :-)  Or maybe not:

> As it turns out Perl is one of the worst as far as being able to recreate
> its own internal binary representation based on its self-generated textual
> representation. I became comfortable (perhaps too comfortable) with being
> able to convert doubles back and forth between string and binary form,
> reliably and repeatably, in most languages, but I couldn't make this happen
> in Perl (version 4.0 IIRC).
> 
> Without realizing it, I had come to assume that a language's base ten
> textual representation for a double or a float would be readable by that
> same language and when reconverted (base ten -> base two) produce an exact
> copy of the original binary form, and this is true in most languages. Then
> a Perl programmer challenged me on this, saying the base ten representation
> almost never recreated the original binary number, and I tried to show that
> wasn't true. I wrote test suites in Java, C and C++ (the latter not using
> printf and scanf) and Perl, and the results were perfect in every language
> except Perl.

One more reason to not use Perl. :-)  The question is whether one should 
rely on the binary <-> text conversion.  The best for decimal accuracy 
is probably BCD anyway...

Kind regards

	robert