bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Is -M enabled by default?


From: Nelson H. F. Beebe
Subject: Re: [bug-gawk] Is -M enabled by default?
Date: Mon, 12 Feb 2018 17:07:31 -0700

>> > gawk -e 'BEGIN{ x = 1; for(i=1;i<1000;++i) { x = x * 2; printf("%4d  
>> > %.3e\n", i, x)} }'
>> The above code does not prove x is stored as double, because even if x
>> is stored as an arbitrary precision integer, it still can be converted
>> to double and printed with %e. Is there a way to print the underlying

Just change the loop limit in your original version from 1023 to 1025;
when i = 1024, the output number changes to "inf", because the computation
has overflowed.  The largest IEEE 754 64-bit binary format number is
+0x1.fffffffffffffp+1023 ~= 1.797_693_134_862_315_7e+308.

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: address@hidden  -
- 155 S 1400 E RM 233                       address@hidden  address@hidden -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]