Skip to content

Numeric Type

Jeremie Rossignol edited this page Dec 6, 2018 · 9 revisions

The numeric data types include types such as int, short, float and double. For this section, they are together referred to as numeric.

Local Functions

Function Signature Description
numeric Random() Returns a random number that is greater than or equal to 0.0, but less than 1.0. Note for integer types this will always return 0 - use the second interface instead.
numeric Random(numericmin,numeric max) Returns a random number that is greater than or equal to min, but less than max.
numeric Min(numerica,numeric b) Returns whichever is smallest out of a and b.
numeric Max(numerica,numeric b) Returns whichever is largest out of a and b.
numeric Pow(numerica,numeric b) Returns a to the power of b.
numeric Log(numerica,numeric b) Returns the logarithm of a in base b.
numeric Round(numeric value) Rounds the number to the nearest full integer value (uses bankers rounding).
numeric Round(numericvalue,numeric precision) Rounds the number to the nearest multiple of precision. For example Round(113.0, 5.0) would return 115.0.
numeric Sin(numeric a) Calculates the sine of the angle specified in radians.
numeric Cos(numeric a) Calculates the cosine of the angle specified in radians.
numeric Tan(numeric a) Calculates the tangent of the angle specified in radians.
numeric Asin(numeric a) Calculates the arcsine of the angle specified in radians.
numeric Acos(numeric a) Calculates the arccosine of the angle specified in radians.
numeric Atan(numeric a) Calculates the arctangent of the angle specified in radians.
numeric Sinh(numeric a) Calculates the hyperbolic sine of the angle specified in radians.
numeric Cosh(numeric a) Calculates the hyperbolic cosine of the angle specified in radians.
numeric Tanh(numeric a) Calculates the hyperbolic tangent of the angle specified in radians.

Global Functions

Function Signature Description
int int(numeric val) Converts the value to an integer representation.
long long(numeric val) Converts the value to a long integer representation.
uint uint(numeric val) Converts the value to an unsigned integer representation.
ulong ulong(numeric val) Converts the value to an unsigned long integer representation.
float float(numeric val) Converts the value to a float (single precision) representation.
double double(numeric val) Converts the value to a float (double precision) representation.

Methods

Method Signature Description
string Print() Returns the pretty-printed string value of the number, using the following rules:
  1. Integer numbers less than 10 are printed in english ("one", "two", etc.)
  2. Numbers greater than 1000 use the number grouping separator (not sure if KSP respects locale in this). For example "1,000", "1,000,000".
  3. Real numbers are printed with two decimal places.
  4. Real numbers less than 1.0 are printed with five decimal places.
string ToString(string format) Converts to a string using the given C# format expression.
Clone this wiki locally