fn: precision
[contents]

Contents

Syntax

The syntax for precision calls is:

f++:  
precision()
precision(param)

n++:  
@precision()
@precision(param)

Description

The precision function either:

  • takes zero parameters and returns the current level of precision that is set when writing doubles
  • takes a single parameter that is either an integer to set to level of precision when writing doubles or a string to set the type of precision used when writing doubles

The following are valid parameters for precision calls:

param description
[nonNegInteger] maximum number of decimal places
defaultfloat write floating-point values in default floating-point notation (default)
fixed write floating-point values in fixed-point notation
!fixed unset writing floating-point values in fixed-point notation.
scientific write floating-point values in scientific notation
!scientific unset writing floating-point values in scientific notation
hexfloat write floating-point values in hexadecimal format (same as fixed and scientific)
!hexfloat unset writing floating-point values in hexadecimal format
param description
You can find more information about fixed, scientific, hexfloat and defaultfloat here.

f++ example

Examples of precision being used with f++:

:=(double, d=1.23456)
precision("fixed")
precision(3)
console(d)

n++ example

Example of precision being used with n++:

@:=(double, d=1.23456)
@precision("fixed")
@precision(3)
@console(d)