all repos — min @ 046a0b98142765473daeff9af45d4adc3ca534b3

A small but practical concatenative programming language.

site/contents/reference-num.md

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
-----
content-type: "page"
title: "num Module"
-----
{@ _defs_.md || 0 @}

{#op||+||{{n1}} {{n2}}||{{n3}}||
Sums {{n1}} and {{n2}}. #}

{#op||-||{{n1}} {{n2}}||{{n3}}||
Subtracts {{n2}} from {{n1}}. #}

{#op||-inf||{{none}}||{{n}}||
Returns negative infinity. #}

{#op||*||{{n1}} {{n2}}||{{n3}}||
Multiplies {{n1}} by {{n2}}. #}

{#op||/||{{n1}} {{n2}}||{{n3}}||
Divides {{n1}} by {{n2}}. #}

{#op||avg||{{q}}||{{n}}||
Returns the average of the items of {{q}}. #}

{#op||base||["dec"|"hex"|"oct"|"bin"](class:kwd)||{{none}}||
Sets the numeric base used to represent integers. #}

{#op||base?||{{none}}||["dec"|"hex"|"oct"|"bin"](class:kwd)||
Returns the numeric base currently used to represent integers (default: ["dec"](class:kwd)). #}

{#op||bitand||{{i1}} {{i2}}||{{i3}}||
Computes the bitwise *and* of integer {{i1}} and {{i2}}.#}

{#op||bitclear||{{i1}} {{q}}||{{i2}}||
Sets the bytes specified via their position in {{i1}} through {{q}} to 0. #}

{#op||bitflip||{{i1}} {{q}}||{{i2}}||
Flips the bytes specified via their position in {{i1}} through {{q}}. #}

{#op||bitnot||{{i1}}||{{i2}}||
Computes the bitwise *complement* of {{i1}}.#}

{#op||bitor||{{i1}} {{i2}}||{{i3}}||
Computes the bitwise *or* of integers {{i1}} and {{i2}}.#}

{#op||bitparity||{{i1}}||{{i2}}||
Calculate the bit parity in {{i1}}. If the number of 1-bits is odd, the parity is 1, otherwise 0.#}

{#op||bitset||{{i1}} {{q}}||{{i2}}||
Sets the bytes specified via their position in {{i1}} through {{q}} to 0. #}

{#op||bitxor||{{i1}} {{i2}}||{{i3}}||
Computes the bitwise *xor* of integers {{i1}} and {{i2}}.#}

{#op||even?||{{i}}||{{b}}||
Returns {{t}} if {{i}} is even, {{f}} otherwise. #}

{#op||div||{{i1}} {{i2}}||{{i3}}||
Divides {{i1}} by {{i2}} (integer division). #}

{#op||inf||{{none}}||{{n}}||
Returns infinity. #}

{#op||med||{{q}}||{{n}}||
Returns the median of the items of {{q}}. #}

{#op||mod||{{i1}} {{i2}}||{{i3}}||
Returns the integer module of {{i1}} divided by {{i2}}. #}

{#op||nan||{{none}}||nan||
Returns **NaN** (not a number). #}

{#op||odd?||{{i}}||{{b}}||
Returns {{t}} if {{i}} is odd, {{f}} otherwise. #}

{#op||pred||{{i1}}||{{i2}}||
Returns the predecessor of {{i1}}.#}

{#op||product||{{q}}||{{i}}||
Returns the product of all items of {{q}}. {{q}} is a quotation of integers. #}

{#op||random||{{i1}}||{{i2}}||
> Returns a random number {{i2}} between 0 and {{i1}}-1. 
> 
> > %note%
> > Note
> > 
> > You must call `randomize` to initialize the random number generator, otherwise the same sequence of numbers will be returned.#}

{#op||randomize||{{none}}||{{null}||
Initializes the random number generator using a seed based on the current timestamp. #}

{#op||range||{{q2}}||{{q2}}||
Takes a quotation {{q1}} of two or three integers in the form of *start*, *end* and an optional *step* (1 if not specified) and generates the sequence and returns the resulting quotation of integers {{q2}}. #}

{#op||shl||{{i1}} {{i2}}||{{i3}}||
Computes the *shift left* operation of {{i1}} and {{i2}}.#}

{#op||shr||{{i1}} {{i2}}||{{i3}}||
Computes the *shift right* operation of {{i1}} and {{i2}}.#}

{#op||succ||{{i1}}||{{i2}}||
Returns the successor of {{i1}}.#}

{#op||sum||{{q}}||{{i}}||
Returns the sum of all items of {{q}}. {{q}} is a quotation of integers. #}