[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GAWK 5.1.0 doesn't work with 64bit numbers
From: |
Nelson H. F. Beebe |
Subject: |
Re: GAWK 5.1.0 doesn't work with 64bit numbers |
Date: |
Sun, 21 Mar 2021 08:14:26 -0600 |
Hans Riehm reports that assignment of 64-bit integers
x0 = 0x736f6d6570736575
does not reproduce them when printed:
printf("%X\n", x0)
736F6D6570736400
The awk language since its introduction in the 1980s has always had
just two data types: strings and numbers. The latter are by default
represented as the C type double, which on modern systems is always
the IEEE 754 64-bit format, with a 1-bit sign, 11-bit biased
exponent, 1 hidden (not stored) leading bit before the binary
point, and a stored 52-bit fraction. Thus, the largest integer
that is exactly represent in that format has at most 53 bits.
The behavior that Hans reported may be surprising, but it is not a
bug.
-------------------------------------------------------------------------------
- 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: beebe@math.utah.edu -
- 155 S 1400 E RM 233 beebe@acm.org beebe@computer.org -
- Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------