Jump to content
  • Advertisement
Sign in to follow this  
Jason Goepel

Floating Point Literals

This topic is 1912 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm not sure if this is intentional or not, but the following produces produces a compiler error.

 

[source]double 1e5;[/source]

 

It looks like the parser is treating the "1" character as a complete token and an integer literal, so the "e" character is unexpected.  The function "asStringScanDouble", however, is able to convert the string "1e5" to the appropriate double.

 

The parser requires a "." for all floating point literals.  Can we change the parser to also interpret the presence of the "e" or "E" character as a double?

 

The following change to the asCTokenizer::IsConstant function (line 258 of "as_tokenizer.cpp") seems to be the only change needed to make this happen.

 

[source]if( n < sourceLength && source[n] == '.' )[/source]

 

becomes...

 

[source]if( n < sourceLength && (source[n] == '.' || source[n] =='e' || source[n] == 'E') )[/source]

 

Thanks

Edited by Jason Goepel

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!