Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: motorollin on September 12, 2007, 02:56:34 PM

Title: BlitzMax :+ operator
Post by: motorollin on September 12, 2007, 02:56:34 PM
I know this isn't an Amiga language, but I'm porting something from BiltzMax to C++ which may eventually be ported to the Amiga. The code contains the operator :+ in a mathematical function. What is the meaning of this operator? I tried using :+ in C++ but got a warning from the compiler that the statement has no effect.

TIA

--
moto
Title: Re: BlitzMax :+ operator
Post by: jj on September 12, 2007, 03:22:30 PM
I have the blitzmax docuemntation in the house, though never used it, i could look for you when i get home later this evening if you like
Title: Re: BlitzMax :+ operator
Post by: Thomas on September 12, 2007, 03:35:16 PM

I'd guess it's similar to += or ++ in C.

Could you give an example ? It's difficult to guess without context.

Bye,
Thomas
Title: Re: BlitzMax :+ operator
Post by: motorollin on September 12, 2007, 04:27:26 PM
I have just learned from an example that it is equivalent to += in C:

Quote
If you want to increase a variable, let say speed. You can write Speed = Speed + Acceleration Or in a shorter way Speed:+ Acceleration.


From here (http://www.truplo.com/docs/BeginnersGuideToBlitzMax10.pdf).

--
moto
Title: Re: BlitzMax :+ operator
Post by: IonDave on September 12, 2007, 05:05:25 PM
It is equivilent to += in C/C++. Likewise...

:- is -=
:* is *=
:/ is /=
:Mod is %=
:& is &=
:| is |=
:~ is ^=
:Shl is <<=
:Shr (bitwise shift right) is >>= (for unsigned data types*)
:Sar (arithmetic shift right) is >>=

*to get equivilent behaviour for a signed datatype, cast it to an unsigned type first.

[Edited: Thanks SamuraiCrow]
Title: Re: BlitzMax :+ operator
Post by: SamuraiCrow on September 12, 2007, 06:43:50 PM
@IonDave

Isn't that last one a Java operator?  I think an arithmetic shift right is implied if the data type being shifted is signed and logical shift right is implied if the data type is unsigned.
Title: Re: BlitzMax :+ operator
Post by: IonDave on September 13, 2007, 10:57:10 AM
Oh yes, quite right. Which reminds me, this info might be usful if you are porting from Blitz and caught me out on one occasion. With blitz integer types the following signing is implied:

Byte, UNSIGNED
Short, UNSIGNED
Int, SIGNED

As you may have guessed I am primarily a Java programmmer. As BlitzMax shares many traits with java I assumed its integer types are all implicitly SIGNED, doh.  :roll: