You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
This shows you the differences between two versions of the page.
types:float [2015-09-22 10:26 SLT] sei Misplaced header |
types:float [2015-09-22 11:28 SLT] (current) sei missed styling a word |
||
---|---|---|---|
Line 2: | Line 2: | ||
===== Float type ===== | ===== Float type ===== | ||
- | The $ty[float] type represents a number with decimals, as opposed to the [[integer]] type which is for whole numbers only. | + | The $ty[float] type represents a number with decimals, as opposed to the $lty[integer] type which is for whole numbers only. |
Floating-point ($ty[float]) constants can be entered in two formats. The first is by just writing the number with its sign, the decimal point (mandatory for the constant to actually be a float and not an integer), and the decimals. For example, ''3.7'' or ''-5.4164'' are valid float constants. Neither the part to the left of the point nor the part to the right of the point are mandatory (e.g. ''37.'' or ''-.25'' are valid), but a point without any digits around it is not a valid floating-point constant. | Floating-point ($ty[float]) constants can be entered in two formats. The first is by just writing the number with its sign, the decimal point (mandatory for the constant to actually be a float and not an integer), and the decimals. For example, ''3.7'' or ''-5.4164'' are valid float constants. Neither the part to the left of the point nor the part to the right of the point are mandatory (e.g. ''37.'' or ''-.25'' are valid), but a point without any digits around it is not a valid floating-point constant. | ||
Line 94: | Line 94: | ||
// string using 6 decimal places too. | // string using 6 decimal places too. | ||
</code> | </code> | ||
+ | |||
+ | The float value $nan is translated to the string ''NaN'', no matter the kind; the float value $pinf is translated to the string ''Infinity'' and the float value $minf to the string ''-Infinity''. This happens also with other functions that convert floats to string (e.g. $lfn[llList2String], $lfn[llDumpList2String]), except one: $lfn[llList2CSV] translates the float value $nan to the string ''nan'' (if it's regular NaN) or ''-nan'' (if it's the indeterminate kind of NaN), and translates $pinf and $minf to ''inf'' and ''-inf'' respectively. | ||
=== Precision caveats === | === Precision caveats === |