Explorer

core.float-from-decimal

description
The value of the float literal mantissa × 10^exponent. Correctly rounded when |mantissa| < 2^53 and |exponent| <= 22. The compiler computes the same way (core.compile-float-literal)
type
Fn(mantissa: Number, exponent: Number) -> Float
expression
fn(mantissa$0, exponent$1) =>
  match @core.less-than(left: $1, right: 0) {
    true =>
      @core.float-divide(
        left: @core.float-from-integer(value: $0),
        right: @core.float-power-of-ten(n: @core.minus(left: 0, right: $1))
      ),
    false =>
      match @core.equal(left: $1, right: 0) {
        true =>
          @core.float-from-integer(value: $0),
        false =>
          @core.float-multiply(left: @core.float-from-integer(value: $0), right: @core.float-power-of-ten(n: $1))
      }
  }
visibility
public
core.float-from-decimal (project definy, branch localized-descriptions, snapshot 4UAxOcclWZD2NPiuAIppcpCjShSw41vxBIT6qrjlNLc)
id: WYswY-OnjikTX05muhQDWGRjPVGMISq5gG2LGhrIOHA
content hash: OmzobPfWbThMn6XHO5dV2fMSS6VRhGsKIZqAYdoZmgk