• Advertisement
Sign in to follow this  

Support for octals?

This topic is 1790 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

Advertisement
I don't have any plans to implement this myself. However, if you would like to do it and send me a patch I can certainly include it in the SDK.

Regards,
Andreas

Share this post


Link to post
Share on other sites
This was actually quite easy to implement. Any integer that is prefixed with a 0 is considered a octal just like in C. I added a simple test case, but I wasn't sure exactly where to stick it so I put it in test_bits.

Krusu

Share this post


Link to post
Share on other sites
Forgot to check if the number is actually a valid octal (0-7), I'll upload the patch as soon as I fix this. Edited by dkrusu

Share this post


Link to post
Share on other sites
Okay, it now validates the octal. It does add another loop through the numbers, maybe you can think of a better way to validate it?

Share this post


Link to post
Share on other sites

I received another patch from ketmar that added support for binary numbers in addition to octal. I've checked in that in revision 1571.

 

The nice thing about that patch is the consistency with the prefixes, example:

 

int binary = 0b11111111;
int octal = 0o7777;
int decimal = 0d999999;
int hexadecimal = 0xFFFFFFFF;

Share this post


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

  • Advertisement