Home /Examples/examples/java/MathRun.sleela

MathRun.sleela

examples/java/jdk-28/MathRun.sleela · 42 line(s) · sleela

#sleela 3.0
import java.jdk-28;
material;

< Java container: the names used here are housed in /lib/java (selected by the import above) and are not part of the SLeeLa specification, see SLEELA.syntax 38.4. >

< Runs java.lang.Math from lib/java/jdk-28 on the SLeeLa VM (import java.jdk-28 selects it). >
class MathRun {
  void main() {
    print(Math.abs(-7));
    print(Math.abs(-2.5));
    print(Math.max(3, 9));
    print(Math.min(2.5, -1.0));
    print(Math.floor(-2.5));
    print(Math.ceil(2.1));
    print(Math.rint(2.5));
    print(Math.round(2.5));
    print(Math.sqrt(2.0));
    print(Math.cbrt(-27.0));
    print(Math.hypot(3.0, 4.0));
    print(Math.pow(2.0, 10.0));
    print(Math.exp(1.0));
    print(Math.log(Math.E));
    print(Math.log10(1000.0));
    print(Math.sin(Math.PI / 2.0));
    print(Math.cos(0.0));
    print(Math.atan2(1.0, 1.0));
    print(Math.toDegrees(Math.PI));
    print(Math.floorDiv(-7, 2));
    print(Math.floorMod(-7, 3));
    print(Math.ceilDiv(7, 2));
    print(Math.multiplyHigh(9223372036854775807, 4));
    print(Math.getExponent(1024.0));
    print(Math.ulp(1.0));
    print(Math.nextUp(1.0));
    print(Math.signum(-3.0));
    print(Math.clamp(15, 0, 10));
    double r = Math.random();
    print(r >= 0.0 && r < 1.0);
  }
}