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) #

def self.new(object : String | Number) #

Class Method Detail

def self.typedesc #

Instance Method Detail

def %(other : Decimal) : Decimal #

Returns the remainder of this and other decimal numbers.


def &(other : Decimal) : Decimal #

Combines this and other decimals using bitwise and.


def *(other : Decimal) : Decimal #

Returns the product of this and other decimal numbers.


def **(other : Decimal) : Decimal #

Raises this decimal to the power of other.


def +(other : Decimal) : Decimal #

Returns the sum of this and other decimal numbers.


def -(other : Decimal) : Decimal #

Returns the difference between this and other decimal numbers.


def /(other : Decimal) : Decimal #

Returns the quotient of this and other decimal numbers.


def <(other : Decimal) : Bool #

Returns whether this decimal is smaller than other.


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.


def bitcount : Decimal #

Returns the number of bits in this decimal.


def ceil : Decimal #

Rounds this decimal up.


def chr : Char #

Returns the character corresponding to this decimal.


def desc(io : IO) #
Description copied from module Novika::Form

Appends a string description of this form to io.


def each_bit(& : Decimal -> ) #

Yields each bit in this decimal.


def floor : Decimal #

Rounds this decimal down.


def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def i64? #

Returns whether this decimal is in the bounds of Int64.


def in(*ranges) : Decimal #

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


def int : Decimal #

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


def integer? #

Returns whether this decimal is an integer.


def nth_ls_bit(n : Decimal) : Decimal #

Returns n-th least significant bit


def nth_ms_bit?(n : Decimal) : Decimal | Nil #

Returns n-th most significant bit


def posint : Decimal #

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


def rad_cos : Decimal #

Treats this decimal as radians, and returns cosine.


def rad_sin : Decimal #

Treats this decimal as radians, and returns cosine.


def round : Decimal #

Rounds this decimal.


def sqrt : Decimal #

Returns the square root of this decimal.


def to_f32(*args, **options) #

def to_f32(*args, **options, &) #

def to_f64(*args, **options) #

def to_f64(*args, **options, &) #

def to_i : Int32 #

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


def to_i16(*args, **options) #

def to_i16(*args, **options, &) #

def to_i32(*args, **options) #

def to_i32(*args, **options, &) #

def to_i64(*args, **options) #

def to_i64(*args, **options, &) #

def to_i8(*args, **options) #

def to_i8(*args, **options, &) #

def to_s(io) #

def to_u16(*args, **options) #

def to_u16(*args, **options, &) #

def to_u32(*args, **options) #

def to_u32(*args, **options, &) #

def to_u64(*args, **options) #

def to_u64(*args, **options, &) #

def to_u8(*args, **options) #

def to_u8(*args, **options, &) #

def trunc : Decimal #

Truncates this decimal.


def zero? : Bool #

Returns whether this decimal is zero.