About Monkey 2 › Forums › Monkey 2 Development › invalid digit "x" in octal constant
This topic contains 9 replies, has 6 voices, and was last updated by
Mark Sibly
1 year, 8 months ago.
-
AuthorPosts
-
July 26, 2017 at 10:13 pm #9525
Hi all,
Being the tidy sort, I occasionally pad my input params out so all the params line up, but the in the below code:
Monkey123456789101112131415161718192021Class WibbleField i:IntField j:IntMethod New( p:Int, q:Int)i = pj = qEnd MethodEnd ClassFunction Main()New Wibble(1234,1)New Wibble( 8,1)New Wibble(0008,1)End FunctionNew Wibble(0008,1)
Gives an error:
Monkey1234567g++ -c -std=c++11 -m32 -D_WIN32_WINNT=0x0603 -I"C:/Monkey2-v1.1.05b/modules/" -I"C:/Monkey2-v1.1.05b/modules/monkey/native" -I"C:/Users/Sue/Documents/Monkey/" -o "C:/Users/Sue/Documents/Monkey/octalbug.buildv1.1.05/windows_debug/build/_1src_2octalbug_0octalbug.cpp.o" "C:/Users/Sue/Documents/Monkey/octalbug.buildv1.1.05/windows_debug/src/octalbug_octalbug.cpp"C:/Users/Sue/Documents/Monkey/octalbug.buildv1.1.05/windows_debug/src/octalbug_octalbug.cpp:18:29: error: invalid digit "8" in octal constantbbGCNew<t_default_Wibble>(0008,1);^~~~I can happily pad with spaces, but is this expected behavior?
Cheers,
Maff
July 27, 2017 at 12:08 am #9530Definitely a bug. Post it on GitHub. Thats the proper way to report bugs.
July 27, 2017 at 8:05 am #9549Not a bug. Using a leading 0 is how you type numbers in octal with Monkey2, just like typing a leading $ for hexadecimal. I guess you will need to use leading spaces instead
Monkey123456789Function Main()Local a:Int = 31Local b:Int = $1F 'hex for 31Local c:Int = 037 'oct for 31Print a + " " + b + " " + cEndJuly 27, 2017 at 8:30 am #9550Is there a way to type binaries literals with such kind of leading symbol?
July 27, 2017 at 12:01 pm #9553>Not a bug. Using a leading 0 is how you type numbers in octal with Monkey2.
Really! That’s kind of weak. It should have a symbol or something that’s different than just 0s.
July 27, 2017 at 5:16 pm #9558Interesting, thanks
Thought it worth an ask before crying foul.
July 27, 2017 at 9:31 pm #9562Definitely a bug!
This is a horrendous C ‘feature’ that I forgot about that needs to be worked around.
Monkey2 does not (officially) support octal notation.
July 27, 2017 at 11:36 pm #9563Hahaha! That’s what I thought.
July 28, 2017 at 12:11 am #9564I’ve dealt with Hex via StringToLong() and Utf with “hello”[1]
Never had to deal with Octals before; I think. This would be good I presume.July 28, 2017 at 12:22 am #9565Use StringToULong for octals too, eg: Print StringToULong( “100”,8 ) prints 64.
-
AuthorPosts
You must be logged in to reply to this topic.