class Novika::Decimal

Overview

A representation for decimal numbers inside Novika.

Included Modules

Defined in:

novika/forms/decimal.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Novika::Form

a(type : T.class) : T forall T a, desc(io : IO)
desc : String
desc
, die(details : String) die, effect(io)
effect
effect
, on_open(engine : Engine) : self on_open, on_parent_open(engine : Engine) : self on_parent_open, onto(block : Block) : self onto, sel(a, b) sel, to_quote : Quote to_quote

Instance methods inherited from module Novika::Schedulable

schedule(engine : Engine, stack : Block) schedule, schedule!(engine : Engine, stack : Block) schedule!

Constructor Detail

def self.new(val : BigDecimal) #

[View source]
def self.new(object : String | Number) #

[View source]

Class Method Detail

def self.typedesc #

[View source]

Instance Method Detail

def %(other : Decimal) : Decimal #

Returns the remainder of this and other decimal numbers.


[View source]
def &(other : Decimal) : Decimal #

Combines this and other decimals using bitwise and.


[View source]
def *(other : Decimal) : Decimal #

Returns the product of this and other decimal numbers.


[View source]
def **(other : Decimal) : Decimal #

Raises this decimal to the power of other.


[View source]
def +(other : Decimal) : Decimal #

Returns the sum of this and other decimal numbers.


[View source]
def -(other : Decimal) : Decimal #

Returns the difference between this and other decimal numbers.


[View source]
def /(other : Decimal) : Decimal #

Returns the quotient of this and other decimal numbers.


[View source]
def <(other : Decimal) : Bool #

Returns whether this decimal is smaller than other.


[View source]
def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def |(other : Decimal) : Decimal #

Combines this and other decimals using bitwise or.


[View source]
def bitcount : Decimal #

Returns the number of bits in this decimal.


[View source]
def ceil : Decimal #

Rounds this decimal up.


[View source]
def chr : Char #

Returns the character corresponding to this decimal.


[View source]
def desc(io : IO) #
Description copied from module Novika::Form

Appends a string description of this form to io.


[View source]
def each_bit(& : Decimal -> ) #

Yields each bit in this decimal.


[View source]
def floor : Decimal #

Rounds this decimal down.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def i64? #

Returns whether this decimal is in the bounds of Int64.


[View source]
def in(*ranges) : Decimal #

Asserts this decimal is in one of ranges. Dies if it isn't.


[View source]
def int : Decimal #

Asserts this decimal is an integer. Dies if it isn't.


[View source]
def integer? #

Returns whether this decimal is an integer.


[View source]
def nth_ls_bit(n : Decimal) : Decimal #

Returns n-th least significant bit


[View source]
def nth_ms_bit?(n : Decimal) : Decimal | Nil #

Returns n-th most significant bit


[View source]
def posint : Decimal #

Asserts this decimal is a positive integer (i.e., >= 0). Dies if it isn't.


[View source]
def rad_cos : Decimal #

Treats this decimal as radians, and returns cosine.


[View source]
def rad_sin : Decimal #

Treats this decimal as radians, and returns cosine.


[View source]
def round : Decimal #

Rounds this decimal.


[View source]
def sqrt : Decimal #

Returns the square root of this decimal.


[View source]
def to_f32(*args, **options) #

[View source]
def to_f32(*args, **options, &) #

[View source]
def to_f64(*args, **options) #

[View source]
def to_f64(*args, **options, &) #

[View source]
def to_i : Int32 #

Downgrades this decimal into an integer (Int32). Dies if too large.


[View source]
def to_i16(*args, **options) #

[View source]
def to_i16(*args, **options, &) #

[View source]
def to_i32(*args, **options) #

[View source]
def to_i32(*args, **options, &) #

[View source]
def to_i64(*args, **options) #

[View source]
def to_i64(*args, **options, &) #

[View source]
def to_i8(*args, **options) #

[View source]
def to_i8(*args, **options, &) #

[View source]
def to_s(io) #

[View source]
def to_u16(*args, **options) #

[View source]
def to_u16(*args, **options, &) #

[View source]
def to_u32(*args, **options) #

[View source]
def to_u32(*args, **options, &) #

[View source]
def to_u64(*args, **options) #

[View source]
def to_u64(*args, **options, &) #

[View source]
def to_u8(*args, **options) #

[View source]
def to_u8(*args, **options, &) #

[View source]
def trunc : Decimal #

Truncates this decimal.


[View source]
def zero? : Bool #

Returns whether this decimal is zero.


[View source]