simple.util.Math¶
This module contains of functions for performing mathematical operations such as logarithm, square root, trigonometric e.t.c.
It is also a wrapper file for the Mathic dynamic module. The module is loaded once when this file is first call. Using the mathic block directly is not consider safe as it does not check the parameter for incompatible types or object and can result to runtime error. Most of the blocks implemented in this file has a dynamic call but is not consider safe to call the dynamic blocks directly.
Usage
All the blocks are public and does not require any type of initialization because it has no class. All the function in this file is accessible by calling it.
call simple.util.Math
A more elaborate example is present at simple.util.Math Test
copyright: | 2018-2019, Azeez Adewale |
---|---|
license: | MIT License Copyright (c) 2018 simple |
author: | Azeez Adewale <azeezadewale98@gmail.com> |
date: | February 5 2017 |
filename: | Math.sim |
Table Of Content¶
Fields/Blocks/Classes | Summary |
---|---|
module simple.util | |
Called Modules | |
final MathE | Exponential number used in natural log and expApproximation of the mathematical constant e to 11 digit after decimal point. |
final MathPI | The ratio of a circle’s circumference to its diameter.Approximation of the mathematical constant pi / π to 11 digit |
final $MathModule | The math module in a printable string simple.utilites.Math |
final $MathNotNumber | Exception message to indicate the parameter is not a valid number |
final $MathLessThan | Exception message thrown if the parameter is less than a number |
final $MathLessThanOne | Exception message thrown if the parameter is less than 1 |
final $MathLessThanMinusOne | Exception message thrown if the parameter is less than -1 |
final $MathNotBetweenOne | Exception message thrown if the parameter is not between -1 and 1 |
final $MathNotEqual | Exception message to indicate parameter cannot be equal to a number |
block MathE() | Exponential number used in natural log and expApproximation of the mathematical constant e to 11 digit after decimal point. |
block MathPI() | The ratio of a circle’s circumference to its diameter.Approximation of the mathematical constant pi / π to 11 digit |
block abs(number) | Determine the absolute value of a number. Determining the absolute number makes it positive. |
block min(fNumber, sNumber) | Determine the number that is smaller between the two parameters. If both parameter are zerothe first number is negated then the second number is minus from it and the negated result |
block max(fNumber, sNumber) | Determine the number that is larger between the two parameters. If both parameter are zerothe second number is negated and then minus from the first number to give the correct larger |
block sin(number) | Determine the sine trigonometric function sin of a number. The sine value of 0 remainsremain 0. |
block cos(number) | Determine the cosine trigonometric function cos of a number. The cosine value of 0 remainsremain 0. |
block tan(number) | Determine the tangent trigonometric function tan of a number. The tangent value of 0 remains 0. |
block asin(number) | Determine the arc sine trigonometric function arcsin of a number. The arc sine value of 0 remains 0. The range of angles returned is -pi/2 to pi/2 radians (-90 to 90 degrees). |
block acos(number) | Determine the arc cosine trigonometric function arccos of a number. The arc cosine value of 0 remains0. The range of angles returned is -pi/2 to pi/2 radians (-90 to 90 degrees). |
block atan(number) | Determine the arc tangent trigonometric function arctan of a number. The arc tangent value of 0 remains0. The range of angles returned is -pi/2 to pi/2 radians (-90 to 90 degrees). |
block atan2(y, x) | Convert rectangular coordinate (x, y) correct quadrant. It calculate the arc tangent of x and y in the range of -180 and 180 degrees. |
block sinh(number) | Determine the hyperbolic sine of a number. |
block cosh(number) | Determine the hyperbolic cosine of a number. |
block tanh(number) | Determine the hyperbolic tangent of a number. |
block asinh(number) | Determine the nonnegative area hyperbolic sine of a number. |
block acosh(number) | Determine the nonnegative area hyperbolic cosine of a number. |
block atanh(number) | Determine the nonnegative area hyperbolic tangent of a number. |
block exp(number) | Determine the exponential value of a number. The opposite of block log(number) |
block log(number) | Determine the natural logarithm (base-e logarithm) of a number. The opposite of block exp(number) |
block sqrt(number) | Determine the square root of a number. To find cube root of a number call the block cbrt(number) instead,to determine the other root use pow(number, 1/rootNum) |
block cbrt(number) | Determine the cube root of a number. To find square root of a number call the block sqrt(number) instead,to determine the other root use pow(number, 1/rootNum) |
block pow(fNumber,sNumber) | Raise a number to a power of another number. |
block ceil(number) | Determine the nearest integer that is greater than or equal to the number parameter. If the param number is between -1 and 0 the result is -0. |
block floor(number) | Determine the nearest integer that is less than or equal to the number parameter. |
block rint(number) | Determine the value of the number rounded to a nearby integral (as a floating-point value). If the floating-pointsare between two number the Even number will be worked on. It round to the nearest. |
block round(number) | Determine the value of the number rounded to a nearby integral with halfway cases rounded away from zero. The block function is same as floor(number + 0.5f) . It round to the nearest. |
block nearbyint(number) | Determine the value of the number rounded to a nearby integral (as a floating-point value). If the floating-pointsare between two number the Even number will be worked on. It round to the nearest. Similar to block rint(number) block |
block fmod(fNumber,sNumber) | Determine floating point remainder of the fNumber / sNumber with the quotient truncated (rounded towards zero). It round to the nearest. |
block remainder(fNumber,sNumber) | Determine floating point remainder of the fNumber / sNumber. It round to the nearest. Similar to block fmod(fNumber,sNumber) block |
block trunc(number) | Determine the nearest integral value that is not larget in magnitude than the number rounding it toward zero |
block toRadians(number) | Convert from degree to radian using the formula radians = degrees * (pi/180) |
block toDegrees(number) | Convert from radian to degree using the formula degrees = radians * (180/pi) |
block log10(number) | Determine the base 10 logarithm of a number. |
block frexp(number) | Breaks the floating point number into its binary significand (a floating point with an absolute value between 0.5(included) and 1.0(excluded)) and an integral exponent for 2, such that: |
block ldexp(number,exp) | Deterine the result of multiplying the number (the significand) by 2 raised to the power of exp (the exponent) |
block modf(number) | Breaks the number into an integral and a fractional part. The integer part is stored in the object pointed by intpart, and the fractional part is returned by the function. Both parts have the same sign as the number |
block exp2(number) | Determine the base-2 exponential function of a nuber, which is 2 raised to the power the number: 2x |
block expm1(number) | Determine the value of e raised to the power a number minus one: ex-1 |
block ilogb(number) | Determine the integral part of the logarithm of x, using 2 or greater as base for the logarithm.This is the exponent used internally by the machine to express the floating-point value x, when it uses |
block log1p(number) | Determine the natural logarithm of one plus the number. for small magnitude values of number, block log1p(number) may be more accurate than block log(number) log( 1 + x ) |
block log2(number) | Determine the binary (base-2) logarithm of a number |
block logb(number) | Determine the the logarithm of a number, using 2 as base for the logarithm. Almost equivalent to block log2(number) for positive number |
block scalbln(number,exp) | Scales a number by 2 raised to the power of n, returning the result of computing: |
block hypot(x,y) | Determine what would be the square root of the sum of the squares of x and y (as per the Pythagorean theorem), but without incurring in undue overflow or underflow of intermediate values |
block numsign(number) | Determine the sign of the number in the following format |
block vmDecimalPoints(place) | By Default all decimal number in simple-lang is round down to 2 floating point. This block changes the number of floating point decimal are rounded to. Using this block make all the number through out the program have the number |
block random() | Generate a random number |
module simple.util¶
Source: module simple.util Source.
Called Modules¶
Source: Called Modules Source.
final MathE¶
Source: final MathE Source.
Exponential number used in natural log and exp Approximation of the mathematical constant e to 11 digit after decimal point. 2.71828182846.
The e to the first 15 digits after the decimal point is 2.718281828459045
final MathPI¶
Source: final MathPI Source.
The ratio of a circle’s circumference to its diameter. Approximation of the mathematical constant pi / π to 11 digit after the decimal point 3.14159265359. The*pi* / π constant to the first 50 digits after the decimal point.
3.14159 26535 89793 23846 26433 83279 50288 41971 69399 37510
final $MathModule¶
Source: final $MathModule Source.
The math module in a printable string simple.utilites.Math
final $MathNotNumber¶
Source: final $MathNotNumber Source.
Exception message to indicate the parameter is not a valid number
final $MathLessThan¶
Source: final $MathLessThan Source.
Exception message thrown if the parameter is less than a number
final $MathLessThanOne¶
Source: final $MathLessThanOne Source.
Exception message thrown if the parameter is less than 1
final $MathLessThanMinusOne¶
Source: final $MathLessThanMinusOne Source.
Exception message thrown if the parameter is less than -1
final $MathNotBetweenOne¶
Source: final $MathNotBetweenOne Source.
Exception message thrown if the parameter is not between -1 and 1
final $MathNotEqual¶
Source: final $MathNotEqual Source.
Exception message to indicate parameter cannot be equal to a number
block MathE()¶
Source: block MathE() Source.
Exponential number used in natural log and exp Approximation of the mathematical constant e to 11 digit after decimal point. 2.71828182846.
The e to the first 15 digits after the decimal point is 2.718281828459045
- Return:
- the e constant with the first 11 digits after the decimal point
block MathPI()¶
Source: block MathPI() Source.
The ratio of a circle’s circumference to its diameter. Approximation of the mathematical constant pi / π to 11 digit after the decimal point 3.14159265359 The pi / π constant to the first 50 digits after the decimal point.
3.14159 26535 89793 23846 26433 83279 50288 41971 69399 37510
- Return:
- the pi / π constant with the first 11 digits after the decimal point
block abs(number)¶
Source: block abs(number) Source.
Determine the absolute value of a number. Determining the absolute number makes it positive.
- Parameters:
- num : Number
- the number to determine it absolute value
- Throws:
- final $MathNotNumber with title final $MathModule if the parameter is not a number
- Return:
- the absolute value of a number
block min(fNumber, sNumber)¶
Source: block min(fNumber, sNumber) Source.
Determine the number that is smaller between the two parameters. If both parameter are zero the first number is negated then the second number is minus from it and the negated result is returned, this deals with -0 and 0 that might behave strangely and can return 0 to be smaller than -0
- Parameters:
- fNumber : Number
- the first number
- sNumber : Number
- the second number
- Throws:
- final $MathNotNumber with title final $MathModule if one or all the parameters are not number
- Return:
- minimum number of the two numbers
block max(fNumber, sNumber)¶
Source: block max(fNumber, sNumber) Source.
Determine the number that is larger between the two parameters. If both parameter are zero the second number is negated and then minus from the first number to give the correct larger number.
- Parameters:
- fNumber : Number
- the first number
- sNumber : Number
- the second number
- Throws:
- final $MathNotNumber with title final $MathModule if one or all the parameters are not number
- Return:
- larger number of the two numbers
block sin(number)¶
Source: block sin(number) Source.
Determine the sine trigonometric function sin of a number. The sine value of 0 remains remain 0.
- Parameters
- number : Number
- the number to determine it sin value
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the sine value of a radian angle number
block cos(number)¶
Source: block cos(number) Source.
Determine the cosine trigonometric function cos of a number. The cosine value of 0 remains remain 0.
- Parameters
- number : Number
- the number to determine it cos value
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the cosine value of a radian angle number
block tan(number)¶
Source: block tan(number) Source.
Determine the tangent trigonometric function tan of a number. The tangent value of 0 remains 0.
- Parameters
- number : Number
- the number to determine it tan value
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the tangent value of a radian angle number
block asin(number)¶
Source: block asin(number) Source.
Determine the arc sine trigonometric function arcsin of a number. The arc sine value of 0 remains 0. The range of angles returned is -pi/2 to pi/2 radians (-90 to 90 degrees).
- Parameters
- number : Number
- the number to determine it arc sine value
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the arc sine value of the number in radian
block acos(number)¶
Source: block acos(number) Source.
Determine the arc cosine trigonometric function arccos of a number. The arc cosine value of 0 remains 0. The range of angles returned is -pi/2 to pi/2 radians (-90 to 90 degrees).
- Parameters
- number : Number
- the number to determine it arc csine value
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the arc cosine value of the number in radian
block atan(number)¶
Source: block atan(number) Source.
Determine the arc tangent trigonometric function arctan of a number. The arc tangent value of 0 remains 0. The range of angles returned is -pi/2 to pi/2 radians (-90 to 90 degrees).
- Parameters
- number : Number
- the number to determine it arc tangent value
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the arc tangent value of the number in radian
block atan2(y, x)¶
Source: block atan2(y, x) Source.
Convert rectangular coordinate (x, y) correct quadrant. It calculate the arc tangent of x and y in the range of -180 and 180 degrees.
- Parameters
- y : Number
- the floating point value representing a y-coordinate
- x : Number
- the floating point value representing an x-coordinate
- Throws
- final $MathNotNumber with title final $MathModule if one or all the parameters are not number
- Return
- the arc tangent in radian of x/y based on the signs of both values to determine the correct quadrant
block sinh(number)¶
Source: block sinh(number) Source.
Determine the hyperbolic sine of a number.
- Parameters
- number : Number
- the hyperbolic angle
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the hyperbolic sine value of the number
block cosh(number)¶
Source: block cosh(number) Source.
Determine the hyperbolic cosine of a number.
- Parameters
- number : Number
- the hyperbolic angle
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the hyperbolic cosine value of the number
block tanh(number)¶
Source: block tanh(number) Source.
Determine the hyperbolic tangent of a number.
- Parameters
- number : Number
- the hyperbolic angle
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the hyperbolic tangent value of the number
block asinh(number)¶
Source: block asinh(number) Source.
Determine the nonnegative area hyperbolic sine of a number.
- Parameters
- number : Number
- the hyperbolic angle
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the Nonnegative area sine value of the number
block acosh(number)¶
Source: block acosh(number) Source.
Determine the nonnegative area hyperbolic cosine of a number.
- Parameters
- number : Number
- value whose area hyperbolic cosine is computed
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number final $MathLessThanOne with title final $MathModule if the parameter is less than 1
- Return
- Nonnegative area hyperbolic cosine of number, in the interval [0,+INFINITY]
block atanh(number)¶
Source: block atanh(number) Source.
Determine the nonnegative area hyperbolic tangent of a number.
- Parameters
- number : Number
- the value whose area hyperbolic tangent is computed, in the interval [-1,+1]
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number final $MathNotEqual -1 or 1 with title final $MathModule if the parameter is -1 or 1
- Return
- the Nonnegative area tangent value of the number
block exp(number)¶
Source: block exp(number) Source.
Determine the exponential value of a number. The opposite of block log(number)
- Parameters
- number : Number
- the number to raise to the power of
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the exponential value of the number
block log(number)¶
Source: block log(number) Source.
Determine the natural logarithm (base-e logarithm) of a number. The opposite of block exp(number)
- Parameters
- number : Number
- the number to get the natural log of
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the natural logarithm (base-e logarithm) of number
block sqrt(number)¶
Source: block sqrt(number) Source.
Determine the square root of a number. To find cube root of a number call the block cbrt(number) instead, to determine the other root use
pow(number, 1/rootNum)
- Parameters
- number : Number
- the number to get the square root of
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the square root of the number
block cbrt(number)¶
Source: block cbrt(number) Source.
Determine the cube root of a number. To find square root of a number call the block sqrt(number) instead, to determine the other root use
pow(number, 1/rootNum)
- Parameters
- number : Number
- the number to get the cube root of
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the cube root of the number
block pow(fNumber,sNumber)¶
Source: block pow(fNumber,sNumber) Source.
Raise a number to a power of another number.
- Parameters
- fNumber : Number
- the first number to be raised
- sNumber : Number
- the number to be raised to it power
- Throws
- final $MathNotNumber with title final $MathModule if one or all the parameters are not number
- Return
- fNumber raised to the power of sNumber
block ceil(number)¶
Source: block ceil(number) Source.
Determine the nearest integer that is greater than or equal to the number parameter. If the param number is between -1 and 0 the result is -0.
Note
ceil(number) == floor(-number)
- Parameters
- number : Number
- the number to be worked on
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the nearest integer value greater than or equal to the number
block floor(number)¶
Source: block floor(number) Source.
Determine the nearest integer that is less than or equal to the number parameter.
Note
ceil(number) == floor(-number)
- Parameters
- number : Number
- the number to be worked on
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the largest integer value less than or equal to the number
block rint(number)¶
Source: block rint(number) Source.
Determine the value of the number rounded to a nearby integral (as a floating-point value). If the floating-points are between two number the Even number will be worked on. It round to the nearest.
- Parameters
- number : Number
- the number to be rounded
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the number rounded to nearby integral
block round(number)¶
Source: block round(number) Source.
Determine the value of the number rounded to a nearby integral with halfway cases rounded away from zero. The block function is same as
floor(number + 0.5f)
. It round to the nearest.
- Parameters
- number : Number
- the number to be rounded
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the number rounded to nearby integral
block nearbyint(number)¶
Source: block nearbyint(number) Source.
Determine the value of the number rounded to a nearby integral (as a floating-point value). If the floating-points are between two number the Even number will be worked on. It round to the nearest. Similar to block rint(number) block
- Parameters
- number : Number
- the number to be rounded
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the number rounded to nearby integral
block fmod(fNumber,sNumber)¶
Source: block fmod(fNumber,sNumber) Source.
Determine floating point remainder of the fNumber / sNumber with the quotient truncated (rounded towards zero). It round to the nearest.
- Parameters
- fNumber : Number
- value of the quotient numerator
- sNumber : Number
- value of the quotient denominator
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the remainder of dividing the fNumber and sNumber parameters
block remainder(fNumber,sNumber)¶
Source: block remainder(fNumber,sNumber) Source.
Determine floating point remainder of the fNumber / sNumber. It round to the nearest. Similar to block fmod(fNumber,sNumber) block
- Parameters
- fNumber : Number
- value of the quotient numerator
- sNumber : Number
- value of the quotient denominator
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the remainder of dividing the fNumber and sNumber parameters
block trunc(number)¶
Source: block trunc(number) Source.
Determine the nearest integral value that is not larget in magnitude than the number rounding it toward zero
- Parameters
- number : Number
- the number to be truncated
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the number with the floating points truncated
block toRadians(number)¶
Source: block toRadians(number) Source.
Convert from degree to radian using the formula radians = degrees * (pi/180)
- Parameters
- number : Number
- the angle in degrees
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the angle in radians
block toDegrees(number)¶
Source: block toDegrees(number) Source.
Convert from radian to degree using the formula
degrees = radians * (180/pi)
- Parameters
- number : Number
- the angle in radians
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the angle in degrees
block log10(number)¶
Source: block log10(number) Source.
Determine the base 10 logarithm of a number.
- Parameters
- number : Number
- number to get it base 10 logarithm of
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the base 10 logarithm of the number
block frexp(number)¶
Source: block frexp(number) Source.
Breaks the floating point number into its binary significand (a floating point with an absolute value between 0.5(included) and 1.0(excluded)) and an integral exponent for 2, such that:
number = significand * 2 ^ exponentThe exponent is stored in the location pointed by exp, and the significand is the value returned by the function If the number is zero, both parts (significand and exponent) are zero. If the number is negative, the significand returned by this function is negative
- Parameters
- number : Number
- value to be decomposed
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- a list with binary significand of the number at the first index and the value where the exponent is stored at the second index
block ldexp(number,exp)¶
Source: block ldexp(number,exp) Source.
Deterine the result of multiplying the number (the significand) by 2 raised to the power of exp (the exponent)
- Parameters
- number : Number
- point value representing the significand
- exp : Number
- value of the exponent
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- number * 2 ^ exp
block modf(number)¶
Source: block modf(number) Source.
Breaks the number into an integral and a fractional part. The integer part is stored in the object pointed by intpart, and the fractional part is returned by the function. Both parts have the same sign as the number
- Parameters
- number : Number
- the floating point value to break into parts
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the fractional part of x, with the same sign
block exp2(number)¶
Source: block exp2(number) Source.
Determine the base-2 exponential function of a nuber, which is 2 raised to the power the number: 2x
- Parameters
- number : Number
- the value of the exponent
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- 2 raised to the power of the number
block expm1(number)¶
Source: block expm1(number) Source.
Determine the value of e raised to the power a number minus one: ex-1
- Parameters
- number : Number
- the value of the exponent
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- e raised to the power of the number, minus one
block ilogb(number)¶
Source: block ilogb(number) Source.
Determine the integral part of the logarithm of x, using 2 or greater as base for the logarithm. This is the exponent used internally by the machine to express the floating-point value x, when it uses a significand between 1.0 and 2, so that, for a positive number
x = significand * 2 ^ exponentthe value returned by this function is one less than the exponent obtained with block frexp(number) (because of the different significand normalization as [1.0,2.0) instead of [0.5,1.0))
- Parameters
- number : Number
- the value whose ilogb is returned
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the base-2 logarithm of the number
block log1p(number)¶
Source: block log1p(number) Source.
Determine the natural logarithm of one plus the number. for small magnitude values of number, block log1p(number) may be more accurate than block log(number)
log( 1 + x )
- Parameters
- number : Number
- the value whose logarithm is calculated
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number final $MathLessThanMinusOne with title final $MathModule if the parameter is less than -1 final $MathNotEqual -1 with title final $MathModule if the parameter is equals -1
- Return
- the natural logarithm of ( 1 + number )
block log2(number)¶
Source: block log2(number) Source.
Determine the binary (base-2) logarithm of a number
- Parameters
- number : Number
- the value whose logarithm is calculated
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number final $MathLessThan 0 with title final $MathModule if the parameter is less than 0 final $MathNotEqual -1 with title final $MathModule if the parameter is equals -1
- Return
- binary logarithm of the number : log2x
block logb(number)¶
Source: block logb(number) Source.
Determine the the logarithm of a number, using 2 as base for the logarithm. Almost equivalent to block log2(number) for positive number
- Parameters
- number : Number
- the value whose logarithm is calculated
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- base 2 algorith of a nuber
block scalbln(number,exp)¶
Source: block scalbln(number,exp) Source.
Scales a number by 2 raised to the power of n, returning the result of computing:
scalbn(x,n) = x * 2Presumably, the number and n are the components of a floating-point number in the system; In such a case, this block may be optimized to be more efficient than the theoretical operations to compute the value explicitly
- Parameters
- number : Number
- the value representing the significand
- exp : Number
- the value of the exponent
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- x * 2 ^ n
block hypot(x,y)¶
Source: block hypot(x,y) Source.
Determine what would be the square root of the sum of the squares of x and y (as per the Pythagorean theorem), but without incurring in undue overflow or underflow of intermediate values
- Parameters
- x : Number
- the floating point values corresponding to x of a right-angled triangle
- y : Number
- the floating point values corresponding to y of a right-angled triangle
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the hypotenuse of a right-angled triangle whose legs are x and y
block numsign(number)¶
Source: block numsign(number) Source.
Determine the sign of the number in the following format
- If the number is greater than zero, 1.0 is returned
- If the number is less than zero, -1.0 is returned
- If the number is 1.0 or -1.0 the same value is returned
- Parameters
- number : Number
- the number
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
- Return
- the sign of the number
block vmDecimalPoints(place)¶
Source: block vmDecimalPoints(place) Source.
By Default all decimal number in simple-lang is round down to 2 floating point. This block changes the number of floating point decimal are rounded to. Using this block make all the number through out the program have the number of floating point sent as paraneter.
- Parameters
- place : Number
- the number of floating point for all numbers
- Throws
- final $MathNotNumber with title final $MathModule if the parameter is not a Number
block random()¶
Source: block random() Source.
Generate a random number
.
Below are blocks exposed from the Mathic dynamic module
__sin | Determine sine of a number. Use block sin(number) |
__cos | Determine cosine of a number. block cos(number) |
__tan | Determine tangent of a number. Use block tan(number) |
__asin | Determine arc sine of a number. Use block asin(number) |
__acos | Determine arc cosine of a number. Use block acos(number) |
__atan | Determine arc tangent of a number. Use block atan(number) |
__atan2 | Determine arc tangent of a number with two parameters . Use block atan2(y, x) |
__sinh | Determine hyperbolic sine of a number. Use block sinh(number) |
__cosh | Determine hyperbolic cosine of a number. Use block cosh(number) |
__tanh | Determine hyperbolic tangent of a number . Use block tanh(number) |
__asinh | Determine area hyperbolic sine of a number. Use block asinh(number) |
__acosh | Determine area hyperbolic cosine of a number. Use block acosh(number) |
__atanh | Determine area hyperbolic tangent of a number . Use block atanh(number) |
__rint | Round a number to integral value. Use block rint(number) |
__round | Round a number to nearest. Use block round(number) |
__floor | Round a number down. Use block floor(number) |
__ceil | Round a number up. Use block ceil(number) |
__fmod | Determine remainder of division . Use block fmod(fNumber,sNumber) |
__trunc | Truncate a number . Use block trunc(number) |
__remainder | Determine remainder of an operation. Use block remainder(fNumber,sNumber) |
__exp | Determine a number exponential value . Use block exp(number) |
__log | Determine a number natural logarithm . Use block log(number) |
__log10 | Determine a number common logarithm. Use block log10(number) |
__frexp | Get a number significand and exponent. Use block frexp(number) |
__ldexp | Generate value from a significand and exponent. Use block ldexp(number,exp) |
__modf | Break a number into fractional and integral parts. Use block modf(number) |
__exp2 | Determine a number binary logarithm. Use block exp2(number) |
__expm1 | Compute a number exponential minus one. Use block expm1(number) |
__ilogb | Determine a number integer binary logarithm. Use block ilogb(number) |
__log1p | Compute a number logarithm plus one. Use block log1p(number) |
__log2 | Determine a number binary logarithm . Use block log2(number) |
__logb | Determine a number floating-point base logarithm. Use block logb(number) |
__scalbn | Determine a number scale significand using floating-point base exponent. Use block scalbln(number,exp) |
__scalbln | Determine a number scale significand using floating-point base exponent (long). Use block scalbln(number,exp) |
__pow | Raise a number to a power. Use block pow(fNumber,sNumber) |
__sqrt | Compute a number square root. Use block sqrt(number) |
__cbrt | Compute a number cube root. Use block cbrt(number) |
__hypot | Determine a number hypotenuse value. Use block hypot(x,y) |
__rand | Generate a random number. Use block random() |
__decimals | Change the number of floating point of decimal numbers. Use block vmDecimalPoints(place) |
__fabs | Compute a number absolute value. Use block abs(number) |
.