/Crystal 0.31

# struct BigFloat

## Overview

A `BigFloat` can represent arbitrarily large floats.

It is implemented under the hood with GMP.

big.cr
big/big_float.cr
big/number.cr

## Instance Method Summary

, , , , ,

, , , , ,

, , , , ,

### Instance methods inherited from struct `Float`

, , , , , , , , , , , , , , , , , , , , , , , ,

, , , , ,

, , , , ,

, , , , ,

### Instance methods inherited from struct `Number`

, , , , , , , , , , , , , , , , , , , , , ,

, , , , ,

, , , , ,

,

### Instance methods inherited from class `Object`

, , , , , , , , , , , , , , , , , , ,

,

## Instance Method Detail

### def <=>(other : Float32 | Float64)Source

Description copied from module Comparable(Float)

The comparison operator. Returns `0` if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greter than other, or `nil` if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

```# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]```

### def <=>(other : BigFloat)Source

Description copied from module Comparable(Float)

The comparison operator. Returns `0` if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greter than other, or `nil` if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

```# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]```

### def absSource

Description copied from struct Number

Returns the absolute value of this number.

```123.abs  # => 123
-123.abs # => 123```

### def hash(hasher)Source

TODO improve this

### def to_big_iSource

Description copied from struct Float

Returns a `BigInt` representing this float (rounded using `#floor`).

```require "big"

1212341515125412412412421.0.to_big_i```

### def to_s(io : IO) : NilSource

Description copied from class Object

Appends a `String` representation of this object to the given `IO` object.

An object must never append itself to the io argument, as this will in turn call `#to_s(io)` on it.