Number Literals in the Xojo IDE

If I type this:

Var v As Variant = 100

Am I to assume that the compiler will infer that 100 is an Integer which (on macOS will be an Int64)?

Is it possible to force the compiler to infer a different length of integer from a literal? Like so:

Var As Variant = Int32(100)

What I’m asking is can you cast literals?

You can do

Var v As Variant
v = Ctype(100, Int32)
v.Int32Value = 100

Xojo doesn’t have the type identifiers for literals other than &b &h and a few others.

1 Like

Thanks @Meestor_X, that’s helpful. It’s a little verbose isn’t it? Its a shame there is no shortcut way of doing this, much like you can suffix a literal number with L in Java to force it to be a long (rather than int which is the default).

1 Like

The type hint suffixes are unlikely to ever appear in Xojo