00.01.class" error?

Discussion in 'Ruby' started by Sharma Chelluri, Feb 24, 2007.

  1. Hi,

    0.1.class results in float.
    00.1.class results in error?
    SyntaxError: compile error
    (irb):5: no .<digit> floating literal anymore; put 0 before dot
    (irb):5: syntax error
    from (irb):5

    as humans ignore any number of zeros before. why did ruby compiler
    concerned abt it?. why this?. needs a fix to compiler :p

    Sharma Chelluri, Feb 24, 2007
    1. Advertisements

  2. Sharma Chelluri

    Gary Wright Guest

    I think the problem is that floating point literals must be written
    in base 10, unlike integer literals which can be written in octal.
    In your case:


    the parser sees "00" as as 0 written as an octal constant. The parser
    doesn't consider it as the start of a floating point value because
    floating point values must be written in decimal. So after parsing
    the "00" as an integer literal it sees ".1" as a no longer supported
    floating point literal and complains.

    Gary Wright
    Gary Wright, Feb 24, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.