RE: [tcltk-perl] return of 1=>1.0 transformation error
Brought to you by:
hobbs
From: Jeff H. <je...@ac...> - 2004-04-28 18:52:03
|
> > Much better to early stringification early. > > 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: 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. ??? Jeff |