-
Notifications
You must be signed in to change notification settings - Fork 581
numeric.c assumes that NV_DIG+2 will be enough digits for all precision possible in NV #7586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From [email protected]Created by [email protected]It would be greatly appreciated, BTW, if perlbug did not assume that the numeric.c, in the Perl_my_atof2 function, makes the following assumption: /* There is no point in processing more significant digits Digits beyond MAX_SIG_DIGITS are ignored. In some systems and/or modes #ifdef ((defined(VMS) && !defined(__IEEE_FP)) || defined(_UNICOS)) (although UNICOS does not by default use Perl's atof in any event) or -Allen Perl Info
|
From [email protected]The attached program tests for the presence of the bug in numeric.c's |
From [email protected]The attached is a patch to enable testing whether increasing the number |
From [email protected]numeric.c.patch*** numeric.c.old Tue Nov 9 09:38:46 2004
--- numeric.c Tue Nov 9 09:38:46 2004
*************** Perl_my_atof2(pTHX_ const char* orig, NV
*** 875,881 ****
* both the first and last digit, since neither can hold all values from
* 0..9; but for calculating the value we must examine those two digits.
*/
! #define MAX_SIG_DIGITS (NV_DIG+2)
/* the max number we can accumulate in a UV, and still safely do 10*N+9 */
#define MAX_ACCUMULATE ( (UV) ((UV_MAX - 9)/10))
--- 875,888 ----
* both the first and last digit, since neither can hold all values from
* 0..9; but for calculating the value we must examine those two digits.
*/
! #ifdef MAX_SIG_DIG_PLUS
! /* It is not necessarily the case that adding 2 to NV_DIG gets all the
! possible digits in a NV, especially if NVs are not IEEE compliant
! (e.g., long doubles on IRIX) - Allen <[email protected]> */
! # define MAX_SIG_DIGITS (NV_DIG+MAX_SIG_DIG_PLUS)
! #else
! # define MAX_SIG_DIGITS (NV_DIG+2)
! #endif
/* the max number we can accumulate in a UV, and still safely do 10*N+9 */
#define MAX_ACCUMULATE ( (UV) ((UV_MAX - 9)/10))
|
From [email protected]Well, for some reason RT does not seem to have forwarded to p5p the -Allen *** numeric.c.old Tue Nov 9 09:38:46 2004 #!/tmp/allens/perl.5.9.x.4 -w $max_sprintf = 49; # adjust as needed - must be at least 2 higher than max $ok = 1; foreach $num1_length (9..21) { my $num1 = ""; # print "\#NUM1 string ($num1_length):\t" . $num1 . "\n"; my $tmp_num1 = $num1; # print "\#NUM1 number ($num1_length):\t" . $num1 . "\n"; # print "\#NUM1 sprintf ($num1_length):\t" my $sprintf_total = $num1_length + $num2_length; my $num_sprintf = sprintf("%." . $sprintf_total . "E",$num); # print "\#NUM sprintf ($num1_length $num2_length):\t" # print "\#\t\t\t1 23456789111111111122222222223333333333\n"; my $tmp_num = $tmp_num1 . $tmp_num2; # print "\#NUM string ($num1_length $num2_length):\t" . $tmp_num . "\n\n"; $tmp2_num += 0; my $num_added = sprintf("%." . $sprintf_total. "E",$tmp2_num); if ($num_sprintf ne $num_added) { print "\#NUM added ($num1_length $num2_length):\t" if ($ok) { #MAX_SIG_DIG_PLUS=2 (via MAX_SIG_DIG_PLUS undef): #NUM string (13 24): 4321432143214.4321432143214321432143 #NUM sprintf (13 24): 4.3214321432144321432143214321432260000E+12 #NUM added (13 24): 4.3214321432144321432143214321431990000E+12 #NUM string (13 25): 4321432143214.43214321432143214321432 #NUM sprintf (13 25): 4.32143214321443214321432143214322600000E+12 #NUM added (13 25): 4.32143214321443214321432143214319900000E+12 #NUM string (13 26): 4321432143214.432143214321432143214321 #NUM sprintf (13 26): 4.321432143214432143214321432143226000000E+12 #NUM added (13 26): 4.321432143214432143214321432143199000000E+12 #NUM string (13 27): 4321432143214.4321432143214321432143214 #NUM sprintf (13 27): 4.3214321432144321432143214321432260000000E+12 #NUM added (13 27): 4.3214321432144321432143214321431990000000E+12 #NUM string (13 28): 4321432143214.43214321432143214321432143 #NUM sprintf (13 28): 4.32143214321443214321432143214322600000000E+12 #NUM added (13 28): 4.32143214321443214321432143214319900000000E+12 #NUM string (13 29): 4321432143214.432143214321432143214321432 #NUM sprintf (13 29): 4.321432143214432143214321432143226000000000E+12 #NUM added (13 29): 4.321432143214432143214321432143199000000000E+12 #NUM string (13 30): 4321432143214.4321432143214321432143214321 #NUM sprintf (13 30): 4.3214321432144321432143214321432260000000000E+12 #NUM added (13 30): 4.3214321432144321432143214321431990000000000E+12 #NUM string (13 31): 4321432143214.43214321432143214321432143214 #NUM sprintf (13 31): 4.32143214321443214321432143214322600000000000E+12 #NUM added (13 31): 4.32143214321443214321432143214319900000000000E+12 #NUM string (13 32): 4321432143214.432143214321432143214321432143 #NUM sprintf (13 32): 4.321432143214432143214321432143226000000000000E+12 #NUM added (13 32): 4.321432143214432143214321432143199000000000000E+12 #NUM string (13 33): 4321432143214.4321432143214321432143214321432 #NUM sprintf (13 33): 4.3214321432144321432143214321432260000000000000E+12 #NUM added (13 33): 4.3214321432144321432143214321431990000000000000E+12 #NUM string (13 34): 4321432143214.43214321432143214321432143214321 #NUM sprintf (13 34): 4.32143214321443214321432143214322600000000000000E+12 #NUM added (13 34): 4.32143214321443214321432143214319900000000000000E+12 #NUM string (13 35): 4321432143214.432143214321432143214321432143214 #NUM sprintf (13 35): 4.321432143214432143214321432143226000000000000000E+12 #NUM added (13 35): 4.321432143214432143214321432143199000000000000000E+12 #NUM string (13 36): 4321432143214.4321432143214321432143214321432143 #NUM sprintf (13 36): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 36): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 37): 4321432143214.43214321432143214321432143214321432 #NUM sprintf (13 37): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 37): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 38): 4321432143214.432143214321432143214321432143214321 #NUM sprintf (13 38): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 38): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 39): 4321432143214.4321432143214321432143214321432143214 #NUM sprintf (13 39): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 39): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 40): 4321432143214.43214321432143214321432143214321432143 #NUM sprintf (13 40): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 40): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 41): 4321432143214.432143214321432143214321432143214321432 #NUM sprintf (13 41): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 41): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 42): 4321432143214.4321432143214321432143214321432143214321 #NUM sprintf (13 42): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 42): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 43): 4321432143214.43214321432143214321432143214321432143214 #NUM sprintf (13 43): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 43): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 44): 4321432143214.432143214321432143214321432143214321432143 #NUM sprintf (13 44): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 44): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 45): 4321432143214.4321432143214321432143214321432143214321432 #NUM sprintf (13 45): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 45): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 46): 4321432143214.43214321432143214321432143214321432143214321 #NUM sprintf (13 46): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 46): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (13 47): 4321432143214.432143214321432143214321432143214321432143214 #NUM sprintf (13 47): 4.3214321432144321432143214321432260000000000000000E+12 #NUM added (13 47): 4.3214321432144321432143214321431990000000000000000E+12 #NUM string (15 24): 123412341234123.1234123412341234123412 #NUM sprintf (15 24): 1.234123412341231234123412341234126000000E+14 #NUM added (15 24): 1.234123412341231234123412341234117000000E+14 #NUM string (15 25): 123412341234123.12341234123412341234123 #NUM sprintf (15 25): 1.2341234123412312341234123412341260000000E+14 #NUM added (15 25): 1.2341234123412312341234123412341170000000E+14 #NUM string (15 26): 123412341234123.123412341234123412341234 #NUM sprintf (15 26): 1.23412341234123123412341234123412600000000E+14 #NUM added (15 26): 1.23412341234123123412341234123411700000000E+14 #NUM string (15 27): 123412341234123.1234123412341234123412341 #NUM sprintf (15 27): 1.234123412341231234123412341234126000000000E+14 #NUM added (15 27): 1.234123412341231234123412341234117000000000E+14 #NUM string (15 28): 123412341234123.12341234123412341234123412 #NUM sprintf (15 28): 1.2341234123412312341234123412341260000000000E+14 #NUM added (15 28): 1.2341234123412312341234123412341170000000000E+14 #NUM string (15 29): 123412341234123.123412341234123412341234123 #NUM sprintf (15 29): 1.23412341234123123412341234123412600000000000E+14 #NUM added (15 29): 1.23412341234123123412341234123411700000000000E+14 #NUM string (15 30): 123412341234123.1234123412341234123412341234 #NUM sprintf (15 30): 1.234123412341231234123412341234126000000000000E+14 #NUM added (15 30): 1.234123412341231234123412341234117000000000000E+14 #NUM string (15 31): 123412341234123.12341234123412341234123412341 #NUM sprintf (15 31): 1.2341234123412312341234123412341260000000000000E+14 #NUM added (15 31): 1.2341234123412312341234123412341170000000000000E+14 #NUM string (15 32): 123412341234123.123412341234123412341234123412 #NUM sprintf (15 32): 1.23412341234123123412341234123412600000000000000E+14 #NUM added (15 32): 1.23412341234123123412341234123411700000000000000E+14 #NUM string (15 33): 123412341234123.1234123412341234123412341234123 #NUM sprintf (15 33): 1.234123412341231234123412341234126000000000000000E+14 #NUM added (15 33): 1.234123412341231234123412341234117000000000000000E+14 #NUM string (15 34): 123412341234123.12341234123412341234123412341234 #NUM sprintf (15 34): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 34): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 35): 123412341234123.123412341234123412341234123412341 #NUM sprintf (15 35): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 35): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 36): 123412341234123.1234123412341234123412341234123412 #NUM sprintf (15 36): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 36): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 37): 123412341234123.12341234123412341234123412341234123 #NUM sprintf (15 37): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 37): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 38): 123412341234123.123412341234123412341234123412341234 #NUM sprintf (15 38): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 38): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 39): 123412341234123.1234123412341234123412341234123412341 #NUM sprintf (15 39): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 39): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 40): 123412341234123.12341234123412341234123412341234123412 #NUM sprintf (15 40): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 40): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 41): 123412341234123.123412341234123412341234123412341234123 #NUM sprintf (15 41): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 41): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 42): 123412341234123.1234123412341234123412341234123412341234 #NUM sprintf (15 42): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 42): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 43): 123412341234123.12341234123412341234123412341234123412341 #NUM sprintf (15 43): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 43): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 44): 123412341234123.123412341234123412341234123412341234123412 #NUM sprintf (15 44): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 44): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 45): 123412341234123.1234123412341234123412341234123412341234123 #NUM sprintf (15 45): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 45): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 46): 123412341234123.12341234123412341234123412341234123412341234 #NUM sprintf (15 46): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 46): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (15 47): 123412341234123.123412341234123412341234123412341234123412341 #NUM sprintf (15 47): 1.2341234123412312341234123412341260000000000000000E+14 #NUM added (15 47): 1.2341234123412312341234123412341170000000000000000E+14 #NUM string (18 24): 123412341234123412.1234123412341234123412 #NUM sprintf (18 24): 1.234123412341234121234123412341237000000000E+17 #NUM added (18 24): 1.234123412341234121234123412341228000000000E+17 #NUM string (18 25): 123412341234123412.12341234123412341234123 #NUM sprintf (18 25): 1.2341234123412341212341234123412370000000000E+17 #NUM added (18 25): 1.2341234123412341212341234123412280000000000E+17 #NUM string (18 26): 123412341234123412.123412341234123412341234 #NUM sprintf (18 26): 1.23412341234123412123412341234123700000000000E+17 #NUM added (18 26): 1.23412341234123412123412341234122800000000000E+17 #NUM string (18 27): 123412341234123412.1234123412341234123412341 #NUM sprintf (18 27): 1.234123412341234121234123412341237000000000000E+17 #NUM added (18 27): 1.234123412341234121234123412341228000000000000E+17 #NUM string (18 28): 123412341234123412.12341234123412341234123412 #NUM sprintf (18 28): 1.2341234123412341212341234123412370000000000000E+17 #NUM added (18 28): 1.2341234123412341212341234123412280000000000000E+17 #NUM string (18 29): 123412341234123412.123412341234123412341234123 #NUM sprintf (18 29): 1.23412341234123412123412341234123700000000000000E+17 #NUM added (18 29): 1.23412341234123412123412341234122800000000000000E+17 #NUM string (18 30): 123412341234123412.1234123412341234123412341234 #NUM sprintf (18 30): 1.234123412341234121234123412341237000000000000000E+17 #NUM added (18 30): 1.234123412341234121234123412341228000000000000000E+17 #NUM string (18 31): 123412341234123412.12341234123412341234123412341 #NUM sprintf (18 31): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 31): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 32): 123412341234123412.123412341234123412341234123412 #NUM sprintf (18 32): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 32): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 33): 123412341234123412.1234123412341234123412341234123 #NUM sprintf (18 33): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 33): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 34): 123412341234123412.12341234123412341234123412341234 #NUM sprintf (18 34): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 34): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 35): 123412341234123412.123412341234123412341234123412341 #NUM sprintf (18 35): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 35): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 36): 123412341234123412.1234123412341234123412341234123412 #NUM sprintf (18 36): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 36): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 37): 123412341234123412.12341234123412341234123412341234123 #NUM sprintf (18 37): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 37): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 38): 123412341234123412.123412341234123412341234123412341234 #NUM sprintf (18 38): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 38): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 39): 123412341234123412.1234123412341234123412341234123412341 #NUM sprintf (18 39): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 39): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 40): 123412341234123412.12341234123412341234123412341234123412 #NUM sprintf (18 40): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 40): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 41): 123412341234123412.123412341234123412341234123412341234123 #NUM sprintf (18 41): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 41): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 42): 123412341234123412.1234123412341234123412341234123412341234 #NUM sprintf (18 42): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 42): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 43): 123412341234123412.12341234123412341234123412341234123412341 #NUM sprintf (18 43): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 43): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 44): 123412341234123412.123412341234123412341234123412341234123412 #NUM sprintf (18 44): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 44): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 45): 123412341234123412.1234123412341234123412341234123412341234123 #NUM sprintf (18 45): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 45): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 46): 123412341234123412.12341234123412341234123412341234123412341234 #NUM sprintf (18 46): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 46): 1.2341234123412341212341234123412280000000000000000E+17 #NUM string (18 47): 123412341234123412.123412341234123412341234123412341234123412341 #NUM sprintf (18 47): 1.2341234123412341212341234123412370000000000000000E+17 #NUM added (18 47): 1.2341234123412341212341234123412280000000000000000E+17 #MAX_SIG_DIG_PLUS=3: #NUM OK! #MAX_SIG_DIG_PLUS=4: #NUM OK! -- |
The RT System itself - Status changed from 'new' to 'open' |
From @cpansproutOn Tue Nov 09 07:17:35 2004, easmith@beatrice.rutgers.edu wrote:
Thank you. I’ve applied your patch to numeric.c as ffa277e. I have not applied the test yet. How can I detect, from within the test, |
From @cpansproutOn Sun Oct 03 15:57:59 2010, sprout wrote:
Let’s try that again, with all the S’s: Are there version differences, with regard to floating-point semantics? |
From [email protected]Quoting Father Chrysostomos via RT <perlbug-followup@perl.org>:
Quite possibly. You should probably consult with someone who's still -Allen -- |
From @tonycozOn Sun Oct 03 15:57:59 2010, sprout wrote:
I've marked the patch as applied in RT. I expect the fix would be: - some test (as a test, not a standalone script) to test that numeric - updates to hints/ for the appropriate platforms. If this was only IRIX I'd be tempted to simply close the ticket, but Tony |
From @maukeOn Tue Jul 02 00:00:36 2013, tonyc wrote:
This ticket is listed in perl5140delta: IRIX Should it still remain open? |
From @khwilliamsonOn Mon, 22 Feb 2016 13:13:32 -0800, mauke- wrote:
Pinging on this ticket, a year later -- |
RT #41202 referred to above has been fixed (GH #8730 ) and no longer should be a consideration for keeping this ticket open. Given the lack of response in almost 4 years, and that there have been other fixes that could help this, and that RT #47087 (GH #9095) remains open, I will add a reference to this ticket there, and close this. |
Suggested by Nicholas Clark, somewhat tidied to Glossary standards [perl Perl#7586] STDOUT is not flushed before exec(). Nicholas comment in the original fix: It turns out* that $Config{fflushNULL} on HP-UX is *STILL* undef, because fflush(NULL) wrongly closes STDIN if STDIN is a pipe (which is what the Configure test probes for). I wonder if HP are even aware that their platform is still not quite 100% C89 conformant? Of if they'll fix it in time for the 25th anniversary of the first ANSI C standard? (Also, given that that this bug had been present on Solaris, and on early FreeBSDs, I wonder if it's a bug in common code they inherit from, or just convergent mistake making) Nicholas Clark * At least on the system Merijn provides for us.
Migrated from rt.perl.org#32380 (status was 'open')
Searchable as RT32380$
The text was updated successfully, but these errors were encountered: