-----BEGIN PGP SIGNED MESSAGE----- Moin,
On Tuesday 05 July 2005 13:19, Steve Hay wrote: > Compiling Math::BigInt::FastCalc with VC++ produces a couple of > warnings: > > FastCalc.xs(397) : warning C4244: 'function' : conversion from 'double > ' to 'long ', possible loss of data > FastCalc.xs(399) : warning C4244: '+=' : conversion from 'double ' to > 'unsigned int ', possible loss of data > > These both come from the _len XSUB: > > 388: INIT: > 389: AV* a; > 390: SV* temp; > 391: NV elems; > 392: STRLEN len; > 393: > 394: CODE: > 395: a = (AV*)SvRV(x); /* ref to aray, don't check ref */ > 396: elems = (NV) av_len(a); /* number of elems in array */ > 397: temp = *av_fetch(a, elems, 0); /* fetch last element */ > 398: SvPV(temp, len); /* convert to string & store length > */ 399: len += XS_BASE_LEN * elems; > 400: ST(0) = newSViv(len); Hm, I should have commented the code more :) Two things: the array can never be empty, since even zero is represented by [ 0 ] and not []. Thus elems is always 0 or bigger. In addition, I used an NV because the array can contain I32 (or so?) elements, and when each of them is typical 7 digits long, the resulting length could overflow I32. But now that I think about it, if STRLEN is U32, then 7 * MAXINT will also overflow it. This means you could theoretically construct a BigInt with so many parts that you cannot convert it into a string, IIAC. OTOH, constructing such a big array will probably overflow your memory, anyway. And I haven't even thought about 64bit platforms. Ugh. I am not sure what to change in the code now. Best wishes, Tels - -- Signed on Wed Jul 6 21:21:46 2005 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email. Mediawiki graph-extension: http://bloodgate.com/perl/graph/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iQEVAwUBQswwN3cLPEOTuEwVAQEYhwf/TD0Q5Lnf63jmtH3gIREiOsFWaRvYU7D6 cX1ewkKnezQR2AC14PDDjUNsYTYDwKHO72b+zX8P7tCrceMNnjlyQaAAwB/z1gxW ix2xByrtvHqBf1JFJ8FkL2Y12a0SKeg3l8AQ6G9wGQ+yA9rFYlK3J8KWxhRnwygE T+bo0kyAuiF9dZL0GyMbTvBri/Lw/GhvI+SeEYQHFO4OJs4gNtK/Z/Syn8dYTxoV hDL/vyBdDpOPqW7ifb96fsOFgbe+KyzbYwa0+gzSm0SJz6FGnD6OHEFtPWm8F4cW 93hlCOHQuoPkUsVsKmgSEhpbjSSPtJanG39HRs8bt2RplKCrYh/BJA== =WfSi -----END PGP SIGNATURE-----