Welcome, Guest. Please login or register.

Author Topic: BlitzMax :+ operator  (Read 2747 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
BlitzMax :+ operator
« 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
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline jj

  • Lifetime Member
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4052
  • Country: wales
  • Thanked: 2 times
  • Gender: Male
    • Show only replies by jj
Re: BlitzMax :+ operator
« Reply #1 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
“We don't stop playing because we grow old; we grow old because we stop playing.” - George Bernard Shaw

Xbox Live: S0ulA55a551n2
 
Registered MorphsOS 3.13 user on Powerbook G4 15"
 

Offline Thomas

Re: BlitzMax :+ operator
« Reply #2 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

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: BlitzMax :+ operator
« Reply #3 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.

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline IonDave

  • Newbie
  • *
  • Join Date: Jun 2007
  • Posts: 20
    • Show only replies by IonDave
Re: BlitzMax :+ operator
« Reply #4 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]
 

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2281
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: BlitzMax :+ operator
« Reply #5 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.
 

Offline IonDave

  • Newbie
  • *
  • Join Date: Jun 2007
  • Posts: 20
    • Show only replies by IonDave
Re: BlitzMax :+ operator
« Reply #6 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: