RosettaCodeData/Task/Real-constants-and-functions/M2000-Interpreter/real-constants-and-function...

57 lines
2.2 KiB
Plaintext

Module Checkit {
Def exp(x)= 2.71828182845905^x
Print Ln(exp(1))==1
Print Log(10^5)==5
Print Sgn(-5)=-1
Print Abs(-2.10#)=2.1#
Def exptype$(x)=type$(x)
Print exptype$(Abs(-2.1@))="Decimal"
Print exptype$(Abs(-2.1#))="Currency"
Print exptype$(Abs(-2.1~))="Single"
Print exptype$(Abs(-2.212e34~))="Single"
Print exptype$(Abs(-2.212e34))="Double"
Print exptype$(Abs(-12345612345612345&&))="Long Long"
Print exptype$(Abs(-2&))="Long"
Print exptype$(Abs(-2%))="Integer"
Print exptype$(234ub)="Byte"
Print exptype$(4600ud)="Date"
Print exptype$(Sgn(-2.1#))="Integer"
\\ Sgn return integer type
Print exptype$(Sgn(-2.212e34))="Integer"
\\ Log, Len return double
Print exptype$(Log(1000))="Double"
Print exptype$(exp(1%))="Double"
Print exptype$(Ln(1212%))="Double"
\\ power return type Double ^ and ** (are the same)
Print exptype$(2&^2&)="Long" ' for Version <=11 is "Double"
Print exptype$(2&**2&)="Long" ' for Version <=11 is "Double"
Print exptype$(2&*2&)="Long"
\\ 64bit Long Long (from Version 12)
Print exptype$(2&&^2&&)="Long Long"
Print exptype$(2&&**2&&)="Long Long"
Print exptype$(2&& mod 2&&)="Long Long"
Print exptype$(2&& div 2&&)="Long Long"
Print exptype$(2&& / 2&&)="Double"
Print exptype$(2&&*2&)="Long Long"
// Byte only + - * work for byte (byte is unsigned, from 0 to 255)
Print exptype$(2ub^2ub)="Double"
Print exptype$(2ub**2ub)="Double"
Print exptype$(2ub*2ub)="Byte"
Print exptype$(2ub*255ub)="Integer"
try ok {Print exptype$(256ub*255ub), "??"}
If error or not ok then print error$ ' error in exponet Overflow
Print exptype$(2ub mod 2ub)="Double"
Print exptype$(2ub div 2ub)="Double"
Print exptype$(2ub / 2ub)="Double"
Print 2**2=4, 2^2=4, 2^2^2=16, 2**2**2=16
\\ floor() and Int() is the same
Print Int(-2.7)=-3, Int(2.7)=2
Print Floor(-2.7)=-3, Floor(2.7)=2
Print Ceil(-2.7)=-2, Ceil(2.7)=3
Print round(-2.7, 0)=-3, round(2.7, 0)=3
Print round(-2.2, 0)=-2, round(2.2, 0)=2
Print Sqrt(4)=2
}
Checkit