The BlitzMax documentation is not entirely clear on the topic of explicit type casting (type conversation). The automatic conversion doesn't work with this code:
Local aspectRatio:Float = width / height
The variables width and height are of type Int. The expression doesn't automatically evaluate to a Float, so some explicit casting is necessary. One way to force a conversion is by doing this:
Local w:Float = width
Local h:Float = height
Local aspectRatio:Float = w / h
I just hate to have unnecessary (intermediate) variables cluttering up the readability of my code, but can't figure how to do a proper type cast! The documentation talks about "brackets", but using them I just get a compile error. Does anyone know how to do this?
Local aspectRatio:Float = width / height
The variables width and height are of type Int. The expression doesn't automatically evaluate to a Float, so some explicit casting is necessary. One way to force a conversion is by doing this:
Local w:Float = width
Local h:Float = height
Local aspectRatio:Float = w / h
I just hate to have unnecessary (intermediate) variables cluttering up the readability of my code, but can't figure how to do a proper type cast! The documentation talks about "brackets", but using them I just get a compile error. Does anyone know how to do this?