# Copyright 2005 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ ? 44.previous() # value: 43 ? 44.next() # value: 45 ? 253.min(18) # value: 18 ? 33 :DeepFrozen # value: 33 ? 38823752358143578936745893267458923047892347891234789324 :DeepFrozen # value: 38823752358143578936745893267458923047892347891234789324 ? 1.0 :DeepFrozen # value: 1.0 ? 1.0.isNaN() # value: false ? 0.isNaN() # value: false ? NaN.isNaN() # value: true ? Infinity.isNaN() # value: false ? 1.isNaN() # value: false ? (1/0).isNaN() # value: false ? (0/0).isNaN() # value: true ? 0.5.floor() # value: 0 ? 1.0.floor() # value: 1 ? 0.999.floor() # value: 0 ? (-0.25).floor() # value: -1 ? 5.floor() # value: 5 Exponentiation ? 2 ** 16 # value: 65536 ? 3 ** 3 # value: 27 ? 2**32 # value: 4294967296 ? 2 ** -1 # value: 1/2 ? 2 ** -1.0 # value: 0.5 ? 2.0 ** -1 # value: 0.5 ? 2.0 ** -2 # value: 0.25 ? def x := 2.0 ** -0.5 # value: 0.7071067811865476 ? e__quasiParser(E.toQuote(x)).eval(safeScope) - x # value: 0.0 ? 2.0 ** 0.5 # value: 1.4142135623730951 Coercion tests XXX stricter version that checks the guard passed to conformTo ? def like(v) :any { return def conformer { to __conformTo(_) :any { return v }}} # value: ? 1 / like(2) # value: 0.5 ? 1 / like(0) # value: Infinity ? 1 + like(2) # value: 3 ? 1 - like(2) # value: -1 ? 3 * like(5) # value: 15 ? 3.min(like(2)) # value: 2 ? 1.min(like(2)) # value: 1 ? 3.max(like(4)) # value: 4 ? -3 // like(2) # value: -2 ? (-3).truncDivide(like(2)) # value: -1 ? 53 % like(10) # value: 3 ? 53 %% like(10) # value: 3 ? 0 <=> like(0.0) # value: true ? 3 ** like(3) # value: 27 Number formatting XXX Does E-on-Java have any non-base-10 print operation? ? 99.toString() # value: "99" ? 99.toString([].asMap()) # value: "99" ? 99.toString("base" => 2) # value: "1100011" ? 99.toString("base" => 16) # value: "63" ? 254.toString("base" => 16) # value: "fe" ? 99.toString("base" => 37) # problem: base must be in 2..36, not 37 ? 99.toString("base" => 1) # problem: base must be in 2..36, not 1 ? 99.toString("base" => like(10)) # value: "99" Integer coercion ? float64.coerce(1) # value: 1.0 ? 1.__conformTo(any) # value: 1 ? 1.__conformTo(nullOk) # value: 1 Bug: integer's __conformTo would infintely recurse given a typical non-native guard ' ? List.coerce(1) # problem: the int 1 doesn't coerce to a ConstList floor, ceil ? def fc(n) :any { return [n.floor(), n.ceil()] }; null ? fc(1) # value: [1, 1] ? fc(1.0) # value: [1, 1] ? fc(1.5) # value: [1, 2] ? fc(-1.5) # value: [-2, -1]