PG::Numeric
The Postgres numeric type has arbitrary precision, and can be NaN, "not a number".
The default version of Numeric in this driver only has #to_f which
provides approximate conversion. To get true arbitrary precision, there is
an optional extension pg_ext/big_rational, however LibGMP must be
installed.
Constructors
Instance methods
array of numbers from 0-10,000 representing the numeric (not an array of individual digits!)
Appends this struct's name and instance variables names and values to the given IO.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p1.to_s # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"
Returns a BigDecimal representation of the numeric. This retains all precision, but requires LibGMP installed.
Returns a BigRational representation of the numeric. This retains all precision, but requires LibGMP installed.
The approximate representation of the numeric as a 64-bit float.
Very small and very large values may be inaccurate and precision will be
lost. If you require full precision, require the optional big_rational
support and use #to_big_r
NaN returns 0.0.
location of decimal point in digits array can be negative for small numbers such as 0.0000001