From: Ken A. <kan...@bb...> - 2004-06-07 14:24:19
|
So the remaining issue is what should (string->number "08") return. It currently returns #f. i was hoping it would return 8. At 07:27 PM 6/6/2004 -0400, Timothy John Hickey wrote: >I've modified string->number so that in the base 10 case it allows leading zeroes... >The following Unit tests all pass in the current version of JScheme... > > "06/06/2004" ;; literal syntax, TJH > > ;; Default literal syntax is for Java literals, > > ;; but string->number will treat leading zeroes as decimal if base 10 is specified > > (equal? (.getClass '081) jsint.Symbol.class) > > (equal? (.getClass '0123Dig) jsint.Symbol.class) > > (equal? (.getClass '0123) java.lang.Integer.class) > > (equal? (string->number "081" 10) 81) > > (equal? (string->number "010") 10) > > (equal? (string->number "010" 8) 8) > > (equal? (tryCatch (string->number "081" 8) (lambda(e) 'error)) 'error) > > (equal? (string->number "08") #f) > > (equal? (string->number "08" 10) 8) > > (equal? (string->number "10") 8) > > (equal? (string->number "10" 10) 10) > >The implementation of string->number in the base 10 case is > >> public static Object schemeStringToNumber(String tok, int rdx) { >> try { return U.toNum(Long.parseLong(tok, rdx)); } >> catch (NumberFormatException e) { >> try { >> if (rdx!=10) >> return U.FALSE; >> else return new Double(tok); } >> catch (NumberFormatException e2) >> { return U.FALSE; } >> } >> } > >---Tim--- > > > >------------------------------------------------------- >This SF.Net email is sponsored by the new InstallShield X. > From Windows to Linux, servers to mobile, InstallShield X is the one >installation-authoring solution that does it all. Learn more and >evaluate today! http://www.installshield.com/Dev2Dev/0504 >_______________________________________________ >Jscheme-devel mailing list >Jsc...@li... >https://lists.sourceforge.net/lists/listinfo/jscheme-devel |