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
-0.0 has variable Boolean value #9013
Comments
From zefram@fysh.orgCreated by zefram@fysh.orgA negative floating point zero is distinct from a positive zero, and $ perl -le '$a=-0.0; print $a?"true":"false"' But if it is stringified at some point, then it acts as Boolean true, $ perl -le '$a=-0.0; "$a"; print $a?"true":"false"' I'm not sure whether negative zero should be true or false, but I think Perl Info
|
From @davidnicolOn 9/2/07, via RT Zefram <perlbug-followup@perl.org> wrote:
An argument could be made that in the larger picture of Boolean coercion This could be a useful, instructive corner case to help understand the I think we're well within the "well don't do that then" category; on the I'm for "-0" becoming false, along with "0" and "". Then again that change |
The RT System itself - Status changed from 'new' to 'open' |
From shouldbedomo@mac.comOn 2007–09–03, at 21:16, David Nicol wrote:
$ perl -lwe 'print -1/1e309' for IEEEish machines.
In IEEE fp as well as in Perl. Basically, it means "too small for me |
From @ysthOn Mon, September 3, 2007 12:30 pm, Dominic Dunlop wrote:
Aka true. I thought (and I may misremember) the last go round on this |
From nospam-abuse@bloodgate.comOn Monday 03 September 2007 21:30:10 Dominic Dunlop wrote:
# perl -Mbignum -lwe 'print -1/1e309' :) Tels -- "...no one would risk manipulating votes in an election because it's -- Diebold spokesman David Bear |
From zefram@fysh.orgI wrote:
On reflection, I think negative zero should stringify as "0" and be There was a discussion of negative zero for bug#39875 "-0.0 loses -zefram |
From nospam-abuse@bloodgate.comMoin, On Tuesday 11 September 2007 23:52:18 Zefram wrote:
I would welcome this change (That "+0" and "-0" become "0" on All the best, Tels -- "I never forget a face, but in your case I'll be glad to make an -- Groucho Marx |
From @davidnicol
C<use feature IEEEfp;> anyone? -- |
From nospam-abuse@bloodgate.comMoin, On Wednesday 12 September 2007 20:07:57 David Nicol wrote:
Just for the record: I will not add support for "-0" into BigInt et al. - I All the best, Tels -- "If you think the problem is bad now, just wait until we've solved it." -- Arthur Kasspe |
From @cpansproutI think stringifying -0.0 as 0 is the best solution to this. And it seems that Larry Wall was also planning to have perl do that, or was at least toying with the idea. Since version 5.00, there has been an #ifdef FIXNEGATIVEZERO that does it this way. This patch simple removes that #ifdef. Here are some tests. I have no idea where to put them. t/op/numconvert.t sounds like the right place, but is not structured in a way that fits these tests: ok(-0.0 eq "0", 'negative zero stringifies as 0'); |
From @cpansproutInline Patchdiff -Nup blead/sv.c blead-45133--0/sv.c
--- blead/sv.c 2010-08-01 13:50:12.000000000 -0700
+++ blead-45133--0/sv.c 2010-08-07 17:50:48.000000000 -0700
@@ -2775,13 +2775,11 @@ Perl_sv_2pv_flags(pTHX_ register SV *con
{
dVAR;
-#ifdef FIXNEGATIVEZERO
if (len == 2 && tbuf[0] == '-' && tbuf[1] == '0') {
tbuf[0] = '0';
tbuf[1] = 0;
len = 1;
}
-#endif
SvUPGRADE(sv, SVt_PV);
if (lp)
*lp = len;
@@ -2968,12 +2966,10 @@ Perl_sv_2pv_flags(pTHX_ register SV *con
Gconvert(SvNVX(sv), NV_DIG, 0, s);
}
RESTORE_ERRNO;
-#ifdef FIXNEGATIVEZERO
if (*s == '-' && s[1] == '0' && !s[2]) {
s[0] = '0';
s[1] = 0;
}
-#endif
while (*s) s++;
#ifdef hcx
if (s[-1] == '.') |
From @cpansproutOn Sun Aug 08 12:15:41 2010, sprout wrote:
Applied, with Jesse’s approval, as afa7457. |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#45133 (status was 'resolved')
Searchable as RT45133$
The text was updated successfully, but these errors were encountered: