I am testing a Val() algo and would appreciate feedback on whether these formats a) are correct and b) cover the essential stuff.
Thanks, JJ
Quotetb1 db "12345", 0 ; D: 0-9, before and after <=32
tb2 db "$12345", 0 ; H: leading $
tb3 db "0x12345", 0 ; H: 0x
tb4 db "1234e5h", 0 ; H: trailing h, e is a number
tb5 db "10101", 0 ; D: 0-9, before and after <=32
tb6 db "10101d", 0 ; D: trailing d
tb7 db "10101e3", 0 ; D: trailing e with exponent (no h)
tb8 db "10101b", 0 ; B: trailing b
tb9 db "10101y", 0 ; B: trailing y
tb10 db "10101h", 0 ; H: trailing h
tb11 db " -1.2345E-123", 0 ; Dec
tb12 db " ( -1.2345E-123)", 0 ; Dec
tb13 db ".123E9", 0 ; D: valid
tb14 db "123.E9", 0 ; D: valid
tb15 db ".", 0 ; D: valid??
tb16 db "1.2", 0 ; D: valid
tb17 db "1.", 0 ; D: valid
tb18 db ".2", 0 ; D: valid
tb19 db "10101E", 0 ; invalid: trailing e but no exponent
tb20 db "just a text", 0 ; invalid
tb21 db " ( -1.2345e-117) end of bracket ok?", 0 ; D:
maybe i am blind, but i didn't see octal in there (O/Q)
I don't know how far you want to go with error checking, but how about more than one decimal point, or a decimal point in an exponent, or an invalid character in a number (e.g. 012b)?
Don't some languages use a comma as a decimal point?
yup, german does and swedish too i think, probably many more
Quote from: dedndave on December 22, 2009, 01:55:03 AM
maybe i am blind, but i didn't see octal in there (O/Q)
You are not blind, Dave :bg
I have rarely seen octal numbers in recent years, is anybody still using them?
Quote from: MichaelW on December 22, 2009, 02:12:33 AM
I don't know how far you want to go with error checking, but how about more than one decimal point, or a decimal point in an exponent, or an invalid character in a number (e.g. 012b)?
Michael, right now the assumption was that there will be no
deliberately wrong numbers in the text to parse. For example, Windows.inc contains decimals and hex numbers, and occasionally an equate pointing to another decimal or hex number. ML.exe parses windows.inc correctly, and would probably choke if there were two decimal points in a real number... so that is a valid point. Error checking could be done, at a performance penalty.
These formats are missing:
-34
-34d
-23.
-.23
-.23e12
-.23e-12