[Gambas-user] Numeric operation between strings.

Doriano Blengino doriano.blengino at ...1909...
Mon Nov 8 11:52:11 CET 2010


user ha scritto:
> ok i see this but
>
> CStr(-19776) output is it a string?
>
> for example i think there is difference between
>
> DIM sVar1="-19776" AS String
> DIM iVar2=-19776 AS Integer
>
> why Gambas re-convert a string to integer again when see a + operator?
>    
Because gambas has automatic type conversion. So, if it sees a "+" 
operator, which applies to numbers, it tries to convert its arguments to 
integer (or even float?). I think that this feature, if used with a 
grain of salt, can be very handy. When misused (I am not saying you were 
misusing), it can lead to very surprising results. Use the "&" operator, 
and the result will be no more strange.

Hope it helps, regards,
Doriano






More information about the User mailing list