• Modules
    • By category
    • By name
    • Most popular
    • Most downloaded
    • Repository
  • Register
  • Log in
  • Help
    • Start using Ceylon Herd
    • Publish your first module
    • Module publishing guidelines
    • All about Ceylon
    • Keyboard Shortcuts

    • s Focus search module bar
      ? Open this information panel
      j Move selection down
      k Move selection up
      enter Open current selection
Module info
Name
tombentley / ceylon.math / 1.3.3
Ceylon Math Platform Module
Category SDK

The Ceylon SDK

Backends JVM
Maven coordinates org.ceylon-lang:ceylon.math
Compatible Ceylon release JVM: 1.2.x, 1.3.x (latest)
Published Aug 21, 2017
Stats Downloads (JVM): 1141
Source downloads: 671
Authors Tom Bentley
Description

This module provides four APIs:

  • ceylon.math.decimal—an arbitrary-precision decimal numeric type,
  • ceylon.math.whole—an arbitrary-precision integer numeric type,
  • ceylon.math.float—various common mathematical functions for floating-point numbers, and
  • ceylon.math.integer—various common functions for integers.

The types Whole and Decimal are first-class numeric types and support all the usual mathematical operations:

Whole i = wholeNumber(12P);
Whole j = wholeNumber(3);
Whole n = i**j + j;
print(n); //prints 1728000000000000000000000000000000000003

Operations on Decimals can result in a non-terminating decimal representation. In such cases, it is necessary to perform the operations with rounding. The function implicitlyRounded() performs a computation with rounding.

Decimal x = decimalNumber(66.0G);
Decimal y = decimalNumber(100.0T);
Decimal z = decimalNumber(66.0f);
Decimal d = implicitlyRounded(() => (x+z)/y/x, round(40, halfUp));
print(d); //prints 1.000000000000000000000001E-14

Here, the expression (x+z)/y/x, which has no terminating decimal representation, is evaluated with the intermediate result of each constituent operation rounded down to 40 decimal digits.

Dependencies
ceylon.language/1.3.3
java.base/7 JDK
Usage
  • Import
 import ceylon.math "1.3.3";
Module links Members
Imported By
Home
Code repository
Issue tracker
Browse
Download .car
No .js archive
Download source archive
Download module documentation
View API documentation

Ceylon Herd v1.24 Copyright 2012-2023 Red Hat. About