F# NumericLiteral: FromString method
Does anyone know if there is a way to automatically invoke the FromString method of a numeric literal in F#? I have already tried (and succeeded) with the methods FromOne, FromZero, etc but I have no idea how开发者_高级运维 strings could be handled at compile time...
from page 51 of the F# language specification:
xxxx<suffix>
For xxxx = 0 -> NumericLiteral<suffix>.FromZero()
For xxxx = 1 -> NumericLiteral<suffix>.FromOne()
For xxxx in the Int32 range -> NumericLiteral<suffix>.FromInt32(xxxx)
For xxxx in the Int64 range -> NumericLiteral<suffix>.FromInt64(xxxx)
For other numbers -> NumericLiteral<suffix>.FromString("xxxx")
That means, only when the first 4 are not satisfied, FromString
is called. Also, xxxx
must be digits with signs, you cannot use other alphabeta set for xxxx.
I think it's intended for numbers bigger than Int64.MaxValue.
精彩评论