Skip to content

kiwi.lang.Math

Nikos Siatras edited this page Sep 21, 2022 · 5 revisions

Math type contains methods for performing basic numeric and trigonometric functions

Function Math.min(a,b)

Description: Returns the greater of two values. Values can be Byte, UByte, Short, UShort, Long, Ulong, Integer, UInteger, LongInt, ULongInt, Single and Double

Example Code:

#include once "kiwi\kiwi.bi"

Dim a as Double, b as Double
a = 3.14
b = 7.77

print Math.min(a, b)

Function Math.max(a,b)

Description: Returns the greater of two values. Values can be Byte, UByte, Short, UShort, Long, Ulong, Integer, UInteger, LongInt, ULongInt, Single and Double

Example Code:

#include once "kiwi\kiwi.bi"

Dim a as Double, b as Double
a = 3.14
b = 7.77

print Math.max(a, b)

Function Math.random()

Description: Returns a double value with a positive sign, greater than or equal to 0 and less than 1.

Example Code:

#include once "kiwi\kiwi.bi"

' Print a random number greater than or equal to 0 and less than 1
print Math.random()

' Print a random number greater than or equal to 200 and less than 400
Dim min as Integer = 200
Dim max as Integer = 400
print Math.random() * (max - min + 1) + min

Const Math.E

Description: Math.E value is the value that is closer than any other to "e", the base of the natural logarithms. Example Code:

#include once "kiwi\kiwi.bi"

' Prints "e", the base of the natural logarithms
print Math.E

Const Math.PI

Description: Math.Pi value is the value that is closer than any other to "pi", the ratio of the circumference of a circle to its diameter. Example Code:

#include once "kiwi\kiwi.bi"

' Prints "PI", the ratio of the circumference of a circle to its diameter
print Math.PI