automatic typecasting of variables?

Stellaferox

Active Member
Licensed User
Hi,

I want to know whether Basic4ppc automatically typecasts variables. I know it does in certain cases.
The specific question I have is that I want to use a counter that counts up to 133784560. Does it change type when passing the integermaximum or do you have to typecast it from the start. If yes how do you typecast a variable at start?
Marc
 

agraham

Expert
Licensed User
Longtime User
B4PPC is a weakly typed language and normal (non-array) variables are not really typed at all. They are saved as strings and all numeric calculations are done by converting them to and from floating point doubles. Booleans are actually strings with the values "true" and "false".

Arrays ARE typed but ONLY IF you declare them as such, otherwise they are like non-array variables. Calculations done using typed arrays can be somewhat faster than with ordinary variables or arrays as, while they are still converted to and from doubles for calculation, this is a faster process than string conversion.

A note about libraries for completeness, their existence being the reason that B4PPC needs to know about types. B4PPC knows about certain types, such as Color, Boolean, Int16 etc, and converts its' non-array variables to and from these types when a library requires it. Arrrays, to save processing time, are not converted when passed to a library and so must be declared within B4PPC to be whatever type a library requires.
 

Stellaferox

Active Member
Licensed User
Agraham thanks,

But what about ordinary variables? The counter I use starts of as an integer (4 bytes) and moves up to 133784560 (Int64).
 
Top