Bottle.Number (Bottle v0.1.2) View Source

Provides custom guards for numbers

Link to this section Summary

Functions

Guard that passes when a number is a non_neg_float

Guard that passes when a number is a non_neg_integer

Guard that passes when a number is a non_neg_number

Guard that passes when for any float that is not 0.0

Guard that passes when for any positive float

Guard that passes when a number is a pos_integer

Guard that passes when a number is a pos_number

Guard that passes when a number is 0 (including float 0.0)

Guard that passes when for 0.0

Link to this section Functions

Link to this macro

is_non_neg_float(sub)

View Source (macro)

Guard that passes when a number is a non_neg_float

Examples

iex> is_non_neg_float(1) false

iex> is_non_neg_float(1.1) true

iex> is_non_neg_float(0.0) true

iex> is_non_neg_float(0) false

iex> is_non_neg_float(-1) false

iex> is_non_neg_float(-1.1) false

iex> is_non_neg_float({"anything", "else"}) false

Link to this macro

is_non_neg_integer(sub)

View Source (macro)

Guard that passes when a number is a non_neg_integer

Examples

iex> is_non_neg_integer(1) true

iex> is_non_neg_integer(1.1) false

iex> is_non_neg_integer(0) true

iex> is_non_neg_integer(-1) false

iex> is_non_neg_integer({"anything", "else"}) false

Link to this macro

is_non_neg_number(sub)

View Source (macro)

Guard that passes when a number is a non_neg_number

Examples

iex> is_non_neg_number(1) true

iex> is_non_neg_number(1.1) true

iex> is_non_neg_number(0) true

iex> is_non_neg_number(-1) false

iex> is_non_neg_number({"anything", "else"}) false

Link to this macro

is_non_zero_float(sub)

View Source (macro)

Guard that passes when for any float that is not 0.0

Examples

iex> is_non_zero_float(1.1) true

iex> is_non_zero_float(-1.1) true

iex> is_non_zero_float(0.0) false

iex> is_non_zero_float(0) false

iex> is_non_zero_float(1) false

iex> is_non_zero_float(-1) false

iex> is_non_zero_float({"anything", "else"}) false

Link to this macro

is_pos_float(sub)

View Source (macro)

Guard that passes when for any positive float

Examples

iex> is_pos_float(1.1) true

iex> is_pos_float(-1.1) false

iex> is_pos_float(0.0) false

iex> is_pos_float(0) false

iex> is_pos_float(1) false

iex> is_pos_float(-1) false

iex> is_pos_float({"anything", "else"}) false

Link to this macro

is_pos_integer(sub)

View Source (macro)

Guard that passes when a number is a pos_integer

Examples

iex> is_pos_integer(1) true

iex> is_pos_integer(1.1) false

iex> is_pos_integer(0) false

iex> is_pos_integer(-1) false

iex> is_pos_integer({"anything", "else"}) false

Link to this macro

is_pos_number(sub)

View Source (macro)

Guard that passes when a number is a pos_number

Examples

iex> is_pos_number(1) true

iex> is_pos_number(1.1) true

iex> is_pos_number(0) false

iex> is_pos_number(-1) false

iex> is_pos_number(-1.1) false

iex> is_pos_number({"anything", "else"}) false

Guard that passes when a number is 0 (including float 0.0)

Examples

iex> is_zero(0) true

iex> is_zero(0.0) true

iex> is_zero(1) false

iex> is_zero({"anything", "else"}) false

Link to this macro

is_zero_float(sub)

View Source (macro)

Guard that passes when for 0.0

Examples

iex> is_zero_float(0.0) true

iex> is_zero_float(0) false

iex> is_zero_float(1) false

iex> is_zero_float(1.1) false

iex> is_zero_float(-1) false

iex> is_zero_float(-1.1) false

iex> is_zero_float({"anything", "else"}) false