summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorLarry Wall <lwall@netlabs.com>1995-03-15 08:34:28 -0800
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1995-03-14 19:27:16 +0000
commit8bb9dbe4584e4740e744f2e392c02dc263a7baee (patch)
tree3d46266424a7fa20d5a67ac85d7a6100a9ab6911 /sv.c
parentcb0b1708c66ad12be7ce52c00b9565faecc67579 (diff)
downloadperl-8bb9dbe4584e4740e744f2e392c02dc263a7baee.tar.gz
[fix bug in print]
: In perl 5.001 the print function now only outputs one significant digit for the : the results of some mathematical functions. : : $ cat mine : #!/usr/bin/perl : print sqrt(2), "\n"; : print 4 * atan2(1,1), "\n"; : print log(2), "\n"; : $ ./mine : 1 : 3 : 0 Okay, I understand how this one happened. This is a case where a beneficial fix uncovered a bug elsewhere. I changed the constant folder to prefer integer results over double if the numbers are the same. In this case, they aren't, but it leaves the integer value there anyway because the storage is already allocated for it, and it *might* be used in an integer context. And since it's producing a constant, it sets READONLY. Unfortunately, sv_2pv() bogusly preferred the integer value to the double when READONLY was set. This never showed up if you just said print 1.4142135623731; because in that case, there was already a string value. Larry
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sv.c b/sv.c
index 350356a65b..d2fecd0728 100644
--- a/sv.c
+++ b/sv.c
@@ -1246,14 +1246,14 @@ STRLEN *lp;
return s;
}
if (SvREADONLY(sv)) {
- if (SvIOKp(sv)) {
- (void)sprintf(tokenbuf,"%ld",(long)SvIVX(sv));
- goto tokensave;
- }
if (SvNOKp(sv)) {
Gconvert(SvNVX(sv), DBL_DIG, 0, tokenbuf);
goto tokensave;
}
+ if (SvIOKp(sv)) {
+ (void)sprintf(tokenbuf,"%ld",(long)SvIVX(sv));
+ goto tokensave;
+ }
if (dowarn)
warn(warn_uninit);
*lp = 0;