From: Timothy H. <tim...@ma...> - 2003-01-02 20:39:36
|
On Monday, December 30, 2002, at 02:45 PM, Ken Anderson wrote: > Tim, > > I think i should refactor the stringToNumber code to determine the type > and size of the number and then attempt an appropriate conversion. > readWholeNumber seems more complicated than it needs to be, for example > it treats negative numbers specially were you trying to get around some > limitation? Refactoring is always a good idea if it makes to code cleaner, and in this case it probably will. > > Unfortunately, I've noticed that Integer.parseInt throws a numeric > exception for numbers such as 0xDadaCafe 0x80000000 02000000000, while > our current code returns a Long. Long.parseLong has a similar > problem. So, the best thing might be to use Long.parseLong and then > .intValue to get an Integer. > I presume this has to do with numbers being signed, We may want to make it easier for people to switch from Java syntax to R4RS syntax for contants (longs, etc.) In this particular case, "01438" is not a valid Java number and so should probably throw and exception when usingJavaSyntax but should return the integer 1438 when using Scheme lexical syntax. ---Tim--- > > > At 10:48 AM 12/30/2002, Jonathan A Rees wrote: >> I believe the following behavior is incorrect (according to the scheme >> report). >> >> Jscheme 5.0 04/05/2002 http://jscheme.sourceforge.net >>> (string->number "01438") >> 1438.0 >>> >> >> It should be more like the following: >> >>> (string->number "1438") >> 1438 >>> >> >> Jonathan >> >> >> ------------------------------------------------------- >> This sf.net email is sponsored by:ThinkGeek >> Welcome to geek heaven. >> http://thinkgeek.com/sf >> _______________________________________________ >> Jscheme-user mailing list >> Jsc...@li... >> https://lists.sourceforge.net/lists/listinfo/jscheme-user > |