#.require. clr # revisit this for Java when decide and implement what to do about Decimal Type namespace Test class Test def main is shared d as decimal = 1.0 assert d assert d==1.0 assert d==1 assert d==1d d = 1 assert d == 1.0 d = 1d assert d == 1.0 # this simple test, with only 10 additions, would fail for float64 sum as decimal = 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1 assert sum==1.0 # and this one too: assert sum==0.1*10 # division d = 3.0 assert d / 5.0 == 0.6 assert d // 5 == 0.0 assert 1.0 inherits decimal # .warning. is always assert 1 inherits int # .warning. is always assert not (1 inherits decimal) # .warning. is never # can use the 'd' suffix to be explicit assert 1.0d == 1.0 # can assign ints to decimals d = 7 # can compare ints and decimals assert d > 0 assert 0 < d .testAugmentedAssignment def testAugmentedAssignment is shared d as decimal = 1.0 d += 1.0 assert d == 2.0 d += 2.1 assert d == 4.1 d -= 2.1 assert d == 2.0 d *= 3.5 assert d == 7.0 d /= 3.5 assert d == 2.0 d = 3.0 d /= 5.0 assert d == 0.6 d = 3.0 d //= 5 assert d == 0