Even or odd: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 2,700: | Line 2,700: | ||
=={{header|M2000 Interpreter}}== |
=={{header|M2000 Interpreter}}== |
||
Binary.Add take any numeric type, but value |
Binary.Add take any numeric type, but value from newer versions can trait as unsigned with range of 0 to 0xFFFFFFFF (so if the number is out of this range, a cut made). |
||
Print binary.and(0xFFFFFFF+10, 0XF)=9 |
|||
So Mod if a perfect choice, using it with Decimals (character @ indicate a Decimal type or literal). |
So Mod if a perfect choice, using it with Decimals (character @ indicate a Decimal type or literal). |
||
Variable a take the type of input. There is no reason here to write it as def Odd(a as decimal)= binary.and(Abs(a), 1)=1 |
Variable a take the type of input. There is no reason here to write it as def Odd(a as decimal)= binary.and(Abs(a), 1)=1 |
||
Def used to define variables (an error occur if same variable exist), or to define one line local functions. If a function exist then replace code. This is the same for modules/functions, a newer definition alter an old definition with same name, in current module if they are local, or global if they defined as global, like this |
Def used to define variables (an error occur if same variable exist), or to define one line local functions. If a function exist then replace code. This is the same for modules/functions, a newer definition alter an old definition with same name, in current module if they are local, or global if they defined as global, like this: |
||
Function Global F(x) { code block here}. |
|||
A function F(x) {} is same as |
A function F(x) {} is same as |
||
<pre > |
<pre > |
||
Function F { |
Function F { |
||
Line 2,729: | Line 2,735: | ||
Def Odd(a)= binary.and(Abs(a), 1)=1 |
Def Odd(a)= binary.and(Abs(a), 1)=1 |
||
Print Odd(-5), Odd(6), Odd(11) |
Print Odd(-5), Odd(6), Odd(11) |
||
⚫ | |||
Try { |
|||
⚫ | |||
} |
|||
Print Error$ ' overflow |
|||
def Odd(a)= Int(Abs(a)) mod 2 =1 |
def Odd(a)= Int(Abs(a)) mod 2 =1 |
||
Print Odd(21212121212122122122121@) |
Print Odd(21212121212122122122121@) |