Yes
Drifter, the
^ (circumflex) character is used to raise a number to a given power, (i.e. multiply a number by itself):
Print 2^4 : Rem Using the power symbol here
Print 2*2*2*2 : Rem is the same as doing this
Wait key
End
Another example program using the power symbol:
Rem Use of the ^ Power Operator
Dim SIMBYTE(7,1)
Repeat
CLS 0 : Set Cursor 0,0 :Ink RGB(255,255,255),RGB(0,0,0)
Print "Byte Simulation"
Print
Print "Bits Value = ";
For BITVAL=7 to 0 Step -1
If BITVAL Mod 2 =1
Ink RGB(0,127,191),RGB(0,0,0)
Else
Ink RGB(63,159,191),RGB(0,0,0)
EndIf
SIMBYTE(BITVAL,0)=2^BITVAL
If SIMBYTE(BITVAL,0)>99
Print SIMBYTE(BITVAL,0);" ";
Else
If SIMBYTE(BITVAL,0)>9
Print " ";SIMBYTE(BITVAL,0);" ";
Else
Print " ";SIMBYTE(BITVAL,0);" ";
EndIf
EndIf
Next BITVAL
Print
Ink RGB(0,239,0),RGB(0,0,0) : Print "ON";
Ink RGB(255,255,255),RGB(0,0,0) : Print "/";
Ink RGB(191,31,31),RGB(0,0,0) : Print "OFF";
Ink RGB(255,255,255),RGB(0,0,0) : Print " = ";
For BITVAL=7 to 0 Step -1
SIMBYTE(BITVAL,1)=RND(1)
If SIMBYTE(BITVAL,1)=1
Ink RGB(0,239,0),RGB(0,0,0)
Else
Ink RGB(191,31,31),RGB(0,0,0)
EndIf
Print " ";SIMBYTE(BITVAL,1);" ";
Next BITVAL
BYTETOTAL=0
For BITVAL=0 to 7
If SIMBYTE(BITVAL,1)=1 Then BYTETOTAL=BYTETOTAL+SIMBYTE(BITVAL,0)
Next BITVAL
Set Cursor 0,0 : Ink RGB(255,255,255),RGB(0,0,0) : Print : Print : Print
Print Space$(50);"Byte Total = ";BYTETOTAL
Wait Key
Until Scancode()=1
Philip, that
x^=m formulae you've given does seem to be
C's shorthand use of the assignment operator, so:
x^=m is shorthand for:
x=x^m, as
Kentaree said.
Otherwise, if the formulae was a condition you took from an If statement, for example:
If x^=m
Then, it could be shorthand for:
If x^0=m
But if that's the case, why not just write:
If M=1, because any number used with
^0 will always return 1 ???
However, saying that, if it's shorthand for:
If x^1=m, then you've got a case!