Consider the following:
(int "07") => 7
(int "08") => 0
Is this intentional?
/Christer
Bug in (int)
Hello Christer,
It is intentional! Unless told otherwise (see manual), 'int' understands that number strings beginnning with numeral "0" (zero) are octal numbers. Since "08" is not a valid octal number, 'int' stops parsing the octal string at "0" and returns zero as the result.
The manual gives complete details and explains the optional parameters to 'int' to extract the result you might be expecting.
-- Sam
It is intentional! Unless told otherwise (see manual), 'int' understands that number strings beginnning with numeral "0" (zero) are octal numbers. Since "08" is not a valid octal number, 'int' stops parsing the octal string at "0" and returns zero as the result.
The manual gives complete details and explains the optional parameters to 'int' to extract the result you might be expecting.
-- Sam
yes, and 0 (zero) as an indicator for octal numbers is a common thing in programming languages, 'C", Perl and Python do similar, try:
the above executed in a unix/bash shell on Mac OSX
Lutz
Code: Select all
~> echo "print 077" | perl
63
~> echo "print 077" | python
63
Lutz
I've lost one evening a month ago trying to debug similar problem ;-)
something like this will help:
something like this will help:
Code: Select all
(define (int10 i) (int i 0 10))
WBR, Dmi