Even or odd: Difference between revisions

m
No edit summary
Line 2,700:
 
=={{header|M2000 Interpreter}}==
Binary.Add take any numeric type, but value mustfrom benewer inversions 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).
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 Function Global F(x) { code block here}.:
 
Function Global F(x) { code block here}.
 
A function F(x) {} is same as
 
<pre >
Function F {
Line 2,729 ⟶ 2,735:
Def Odd(a)= binary.and(Abs(a), 1)=1
Print Odd(-5), Odd(6), Odd(11)
Print Odd(21212121212122122122121@)
Try {
Print Odd(21212121212122122122121@)
}
Print Error$ ' overflow
def Odd(a)= Int(Abs(a)) mod 2 =1
Print Odd(21212121212122122122121@)
404

edits