numeric.ijs

Script: ~addons/finance/finexec/toolbox/numeric.ijs
Contributor: William Szuch
Updated: 2022 6 26
Depend: nil
Definitions: loaded to locale base
Status: done
Script source: numeric.ijs

Numeric utilities.

Definitions

B bdiff
D dp
F fdiff
I ip, ip1, ip_1, ipneg1, ipneg_1
L log1y
O onesd
R round
S signchange

bdiff (monad)

Type: tacit

Calculate the backward difference in a list of numbers.

Syntax

bdiff(L)
L = list of numbers

Example

  bdiff(i. 12)
_1 _1 _1 _1 _1 _1 _1 _1 _1 _1 _1
  bdiff(0 2 1 3 12.1)
_2 1 _2 _9.1

dp (monad)

Type: tacit
Get the decimal part of a positive number.

Syntax

ip(N)
N = positive number

Example

   dp(12.12)
0.12
   dp(12)
0
  dp(0 1.1 123.5)
0 0.1 0.5

fdiff (monad)

Type: tacit
Calculate the forward difference in a list of numbers.

Syntax

fdiff(L)
L = list of numbers

Example

  fdiff(i. 12)
1 1 1 1 1 1 1 1 1 1 1
  fdiff(0 2 1 3 12.1)
2 _1 2 9.1

ip (monad)

Type: tacit
Get the integer part of a positive number.

Syntax

ip(N)
N = positive number

Example

   ip(12.12)
12
   ip(12)
12
  ip(0 1.1 123.5)
0 1 123

ip1 (monad)

Type: tacit
Get the integer part of a positive number plus 1.

Syntax

ip1(N)
N = positive number

Example

   ip1(12.12)
13
   ip1(12)
13

ip_1 (monad)

Type: tacit
Get the integer part of a positive number less 1.

Syntax

ip_1(N)
N = positive number

Example

   ip_1(12.12)
11
   ip_1(12)
11

ipneg1 (monad)

Type: tacit
Get the integer part of a negative number plus 1.

Syntax

ipneg1(N)
N = negative number

Example

   ipneg1(_12.12)
_11
   ipneg1(_12)
_11

ipneg_1 (monad)

Type: tacit
Get the integer part of a negative number less 1.

Syntax

ipneg_1(N)
N = negative number

Example

   ipneg_1(_12.12)
_13
   ipneg_1(_12)
_13

log1y (monad)

Type: tacit

Calculate the log of (1+N) to the base e.

Syntax

log1y(N)
N = number

Example

   log1y(12.1)
2.57261
   log1y(_0.999)
_6.90776
   log1y(1 0 _0.9999)
0.693147 0 _9.21034
   log1y(_10)
2.19722j3.14159

onesd (monad)

Type: tacit
Create a list of the number of ones in the integer part
of a positive and catenate the decimal part.

Syntax

onesd(N)
N = number

Example

   onesd(12.12)
1 1 1 1 1 1 1 1 1 1 1 1 0.12
   onesd(12)
1 1 1 1 1 1 1 1 1 1 1 1 0

round (dyad)

Type: tacit
Round Y to nearest X

Syntax

(X)round(Y)
Y = number to be rounded
X = number nearest to be rounded

Example

 (0.01)round(12.123)
12.12
 (1)round(12.123 _12.123 10.1)
12 _12 10
 (10)round(12.123 _12.123 10.1 15.1)
10 _10 10 20

signchange (monad)

Type: tacit
Show if there is a change of sign in between two numbers.
result = 1 if change of sign.
result = _1 if no change of sign.
result = 0 if either number = 0.

Syntax

signchange(A,B) or
signchange(A;B) Boxed
A = number
B = number

Example

   signchange(12,13)
_1
   signchange(12;_12)
1
   signchange(12,12)
_1
   signchange(0,12)
0