Although I've used perl for many years, I've just been surprised (in the unpleasant sense) by a recent event. Given a variable, say "$int", which is a growing integer, I would expect "print $int" to print it as a simple integer; indeed it usually does so. But when its size takes it from 15 decimal digits to 16 decimal digits, that "print" flips the output into scientific notation:
   999999999999997
   999999999999998
   999999999999999
   1e+15
   1e+15

Ouch. The surprise is especially nasty when this output data is then used as input data for another program that expects an integer.

This is consistent across a variety of OSes (although all perl 5.8.8).

I eventually managed to track down a way to achieve the desired result with a non-obvious "printf" format. (I leave that, and its clear user-oriented explanation, as an exercise for the reader!)

I'm not aware of any documentation about this surprise. Is this a program bug or a documentation bug? (Or a self bug?)

Is there a more appropriate forum than "beginn...@..." to raise this?

--
: David Lee
: ECMWF (Data Handling System)
: Shinfield Park
: Reading  RG2 9AX
: Berkshire
:
: tel:    +44-118-9499 362
: email:  david....@ecmwf.int

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to