[Gambas-user] Numeric operation between strings.

Caveat Gambas at ...1950...
Mon Nov 8 10:31:58 CET 2010


Well CStr(-19776) gives -19776 so if you use the arithmetic addition
operator you're gonna get -19776 plus -19776 giving -39552.

Using the arithmetic operator in this case only works if both your
strings can be treated as floats, so this will raise an error:

PRINT CStr(-19776) + CStr("W")

If you used the ampersand (&) instead, like this:

PRINT CStr(-19776) & CStr(-19776)

you'd've gotten the expected(?) result of:

-19776-19776

and:

PRINT CStr(-19776) & CStr("W")

would not fail, but give:

-19776W

Regards,
Caveat

On Mon, 2010-11-08 at 10:51 +0200, user wrote:
> Hi to all and good morning.
> 
> I have this code
> 
> PRINT CStr(-19776) + CStr(-19776)
> 
> and i get -39552
> 
> How this is possible? Numeric operations between Strings?
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a 
> Billion" shares his insights and actions to help propel your 
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user






More information about the User mailing list