Re: [tcltk-perl] return of 1=>1.0 transformation error
Brought to you by:
hobbs
From: Vadim K. <va...@ar...> - 2004-04-28 19:09:46
|
> > Or just add more checks to the code so that it creates int > > objects whenever that would be an exact translation of the > > SV. A few more conditionals and it should be all ok again. > > Vadim - please verify that just removing the "SvIOK(sv) &&" > condition is all that is necessary. IOW: This cures the problem, no more fails in perl-5.6.1. Thank you for providing a fix! > > else if (SvNOK(sv)) { > double dval = SvNV(sv); > int ival; > /* > * Perl does math with doubles by default, so 0 + 1 == 1.0. > * Check for int-equiv doubles and make those ints. > */ > if ((double)(ival = SvIV(sv)) == dval) { > objPtr = Tcl_NewIntObj(ival); > } else { > objPtr = Tcl_NewDoubleObj(dval); > } > } > > we could possibly save a cycle or two with: > > if ((double)(ival = (int)dval) == dval) { > > but I'm not sure avoiding the SvIV is a good idea. ??? I may be wrong, but probably your fix could be #ifdef-ed for perl-5.6.1? But in this case there will be unnecessary complications, IMHO Vadim. |