source: trunk/essentials/sys-apps/gawk/test/longdbl.awk

Last change on this file was 3076, checked in by bird, 18 years ago

gawk 3.1.5

File size: 6.4 KB
Line 
1# From arnold@f7.net Wed Apr 27 09:48:37 2005
2# Return-Path: <arnold@f7.net>
3# Received: from localhost (skeeve [127.0.0.1])
4# by skeeve.com (8.12.11/8.12.11) with ESMTP id j3R6mZVm015791
5# for <arnold@localhost>; Wed, 27 Apr 2005 09:48:37 +0300
6# Received: from pop.012.net.il [84.95.5.221]
7# by localhost with POP3 (fetchmail-6.2.5)
8# for arnold@localhost (single-drop); Wed, 27 Apr 2005 09:48:37 +0300 (IDT)
9# Received: from mtain3.012.net.il ([10.220.5.7])
10# by i_mss3.012.net.il (HyperSendmail v2004.12)
11# with ESMTP id <0IFK00L1DIZ02530@i_mss3.012.net.il> for arobbins@012.net.il;
12# Tue, 26 Apr 2005 22:18:36 +0300 (IDT)
13# Received: from VScan3 ([10.220.20.3])
14# by i_mtain3.012.net.il (HyperSendmail v2004.12)
15# with ESMTP id <0IFK007U1IZ0U980@i_mtain3.012.net.il> for arobbins@012.net.il
16# (ORCPT arobbins@012.net.il); Tue, 26 Apr 2005 22:18:36 +0300 (IDT)
17# Received: from i_mtain1.012.net.il ([10.220.5.1])
18# by VScan3 with InterScan Messaging Security Suite; Tue,
19# 26 Apr 2005 22:15:22 +0300
20# Received: from f7.net ([209.61.216.22])
21# by i_mtain1.012.net.il (HyperSendmail v2004.12)
22# with ESMTP id <0IFK009SIIYRN7G0@i_mtain1.012.net.il> for arobbins@012.net.il;
23# Tue, 26 Apr 2005 22:18:33 +0300 (IDT)
24# Received: (from arnold@localhost) by f7.net (8.11.7-20030920/8.11.7)
25# id j3QJFAg18376 for arobbins@012.net.il; Tue, 26 Apr 2005 15:15:10 -0400
26# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164])
27# by f7.net (8.11.7-20030920/8.11.7) with ESMTP id j3QJF5J18304 for
28# <arnold@skeeve.com>; Tue, 26 Apr 2005 15:15:06 -0400
29# Received: from monty-python.gnu.org ([199.232.76.173])
30# by fencepost.gnu.org with esmtp (Exim 4.34)
31# id 1DQVVh-0004gD-CH for bug-gawk@gnu.org; Tue, 26 Apr 2005 15:14:17 -0400
32# Received: from Debian-exim by monty-python.gnu.org with spam-scanned
33# (Exim 4.34) id 1DQVYa-0002PR-2b for bug-gawk@gnu.org; Tue,
34# 26 Apr 2005 15:17:56 -0400
35# Received: from [129.183.4.8] (helo=ecfrec.frec.bull.fr)
36# by monty-python.gnu.org with esmtp (Exim 4.34)
37# id 1DQVYZ-0002Lr-EF for bug-gawk@gnu.org; Tue, 26 Apr 2005 15:17:15 -0400
38# Received: from localhost (localhost [127.0.0.1])
39# by ecfrec.frec.bull.fr (Postfix) with ESMTP id 5782819D907 for
40# <bug-gawk@gnu.org>; Tue, 26 Apr 2005 21:12:53 +0200 (CEST)
41# Received: from ecfrec.frec.bull.fr ([127.0.0.1])
42# by localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new, port 10024)
43# with ESMTP id 06763-10 for <bug-gawk@gnu.org>; Tue,
44# 26 Apr 2005 21:12:51 +0200 (CEST)
45# Received: from ecn002.frec.bull.fr (ecn002.frec.bull.fr [129.183.4.6])
46# by ecfrec.frec.bull.fr (Postfix) with ESMTP id 4488B19D906 for
47# <bug-gawk@gnu.org>; Tue, 26 Apr 2005 21:12:51 +0200 (CEST)
48# Received: from daphne ([129.183.192.6])
49# by ecn002.frec.bull.fr (Lotus Domino Release 5.0.12)
50# with ESMTP id 2005042621231613:3312 ; Tue, 26 Apr 2005 21:23:16 +0200
51# Date: Tue, 26 Apr 2005 21:12:49 +0200 (CEST)
52# From: Jean-Marc Saffroy <jean-marc.saffroy@ext.bull.net>
53# Subject: GNU awk unable to handle 64-bit ints on IA64
54# X-X-Sender: saffroyj@daphne.frec.bull.fr
55# To: bug-gawk@gnu.org
56# Message-id: <Pine.LNX.4.61.0504261916140.22370@daphne.frec.bull.fr>
57# MIME-version: 1.0
58# Content-type: TEXT/PLAIN; charset=US-ASCII; format=flowed
59# X-MIMETrack: Itemize by SMTP Server on ECN002/FR/BULL(Release 5.0.12 |February
60# 13, 2003) at 26/04/2005 21:23:16,
61# Serialize by Router on ECN002/FR/BULL(Release 5.0.12 |February 13,
62# 2003) at 26/04/2005 21:23:16, Serialize complete at 26/04/2005 21:23:16
63# X-Virus-Scanned: by amavisd-new at frec.bull.fr
64# Original-recipient: rfc822;arobbins@012.net.il
65# X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on skeeve.com
66# X-Spam-Level:
67# X-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00 autolearn=ham
68# version=2.63
69# Status: RO
70#
71#
72# Hello,
73#
74# I have rounding problems when manipulating 64-bit ints (actually they are
75# addresses) on Linux/IA64:
76#
77# $ echo 0xa000000100000813|./gawk '{printf("0x%lx\n",strtonum($1));}'
78# 0xa000000100000800
79# $ echo 0xffffffffffffffff|./gawk '{printf("0x%lx\n",strtonum($1));}'
80# 0x8000000000000000
81# $ ./gawk --version|head -1
82# GNU Awk 3.1.4
83#
84# The problem seems to be that AWKNUM is defined to be a double, which has a
85# 53-bit mantissa. On IA64 with gcc 3.2.3 (maybe other compilers as well)
86# there is a long double type with a larger mantissa:
87#
88# $ grep define.*LDBL_MANT_DIG /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/include/float.h
89# #define LDBL_MANT_DIG 64
90#
91# So I changed AWKNUM to be a long double; this does not seem to be
92# sufficient, because of some dubious casts to double (there may be others
93# left, I didn't check), see patch below. Now it's much nicer:
94#
95# $ echo 0xa000000100000813|./gawk '{printf("0x%lx\n",strtonum($1));}'
96# 0xa000000100000813
97# $ echo 0xffffffffffffffff|./gawk '{printf("0x%lx\n",strtonum($1));}'
98# 0xffffffffffffffff
99#
100# Maybe the gawk configure script should set AWKNUM to be a long double on
101# Linux/IA64?
102#
103#
104# Regards,
105#
106# --
107# Jean-Marc Saffroy - jean-marc.saffroy@ext.bull.net
108#
109#
110# diff -ru gawk-3.1.4/awk.h gawk/awk.h
111# --- gawk-3.1.4/awk.h 2004-07-26 16:11:05.000000000 +0200
112# +++ gawk/awk.h 2005-04-26 19:19:10.545419273 +0200
113# @@ -273,7 +273,7 @@
114# /* ------------------ Constants, Structures, Typedefs ------------------ */
115#
116# #ifndef AWKNUM
117# -#define AWKNUM double
118# +#define AWKNUM long double
119# #endif
120#
121# #ifndef TRUE
122# diff -ru gawk-3.1.4/builtin.c gawk/builtin.c
123# --- gawk-3.1.4/builtin.c 2004-07-13 09:55:28.000000000 +0200
124# +++ gawk/builtin.c 2005-04-26 20:53:41.211365432 +0200
125# @@ -578,7 +578,7 @@
126# char *cend = &cpbuf[30];/* chars, we lose, but seems unlikely */
127# char *cp;
128# const char *fill;
129# - double tmpval;
130# + AWKNUM tmpval;
131# char signchar = FALSE;
132# size_t len;
133# int zero_flag = FALSE;
134# @@ -2773,16 +2773,16 @@
135# do_strtonum(NODE *tree)
136# {
137# NODE *tmp;
138# - double d;
139# + AWKNUM d;
140#
141# tmp = tree_eval(tree->lnode);
142#
143# if ((tmp->flags & (NUMBER|NUMCUR)) != 0)
144# - d = (double) force_number(tmp);
145# + d = (AWKNUM) force_number(tmp);
146# else if (isnondecimal(tmp->stptr))
147# d = nondec2awknum(tmp->stptr, tmp->stlen);
148# else
149# - d = (double) force_number(tmp);
150# + d = (AWKNUM) force_number(tmp);
151#
152# free_temp(tmp);
153# return tmp_number((AWKNUM) d);
154#
155#
156# #####################################################################################
157# This Mail Was Scanned by 012.net Anti Virus Service - Powered by TrendMicro Interscan
158#
159{ printf("0x%lx\n",strtonum($1)); }
Note: See TracBrowser for help on using the repository browser.