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 16:45:45 -0700

Peng Yu <address@hidden> asks on Mon, 12 Feb 2018 16:42:26 -0600
about this one-liner:

>> awk -e 'BEGIN{ x = 1; for(i=1;i<1000;++i) { x = x * 2; print x} }'
>>
>> Do I misunderstand the manual? When does awk use int32, int64 or
>> int128 for an integer?

If you change to code slightly to this

gawk -e 'BEGIN{ x = 1; for(i=1;i<1000;++i) { x = x * 2; printf("%4d  %.3e\n", 
i, x)} }'

you'll get as output

   1  2.000e+00
   2  4.000e+00
   3  8.000e+00
   4  1.600e+01
 ...
 996  6.697e+299
 997  1.339e+300
 998  2.679e+300
 999  5.358e+300

All of those numbers are exactly representable in awk's default of C
type double, which on modern machines in a 64-bit binary (base-2)
format with a range of about 2.22E-308 to 1.79e+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]