From Xojo Documentation

Data Type

A Single is an intrinsic data type that represents a single-precision floating-point number. The default value of a Single is 0.0.

Equals ToText
Shared Methods
FromText Parse


Single is an IEEE single-precision, floating-point value that uses 4 bytes. This means it is speedy but has some limitations in the type of values it can contain. For more information, refer to the wikipedia page about floating point.

In nearly all cases you should use a Double instead of a Single. The only practical cases where you ought to use a Single is when you need to specifically pass a single-precision floating point number to an external function using a Declare.

You should use Currency when dealing with monetary values.

The VarType function returns a value of 4 when passed a Single.

Numerical limits

  • The maximum value of a Single is: ±3.40282346638528859811704183484516925e+38
  • The minimum value towards zero is: ±1.40129846432481707092372958328991613e-45

NaN and Infinity

Singles can hold some special values described below:

  • NaN (i.e. "Not a Number"): occurs if you attempted to perform an illegal mathematical operation, like getting the square root of a negative number. Any further calculation made with a NaN will lead to a NaN value. Str or Format methods return a string beginning with "NaN", e.g. "NaN(021)".
  • Infinity: some calculations lead to an infinite result (positive or negative), e.g. Log( 0 ), or you may exceed the maximum value which can be hold. In such a case, a single will be set to a special value, whose Str will return "INF" (for INFinity) or "-INF" (negative INFinity). Any further calculation will lead to a NaN or infinity value.

Sample Code

The Single and Double data types allow you to store and manage floating point numbers.

Dim s As Single
s = 3.1416

See Also