Documentation

# `Pref`::`floatFormat`

Representation of floating-point numbers

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```Pref::floatFormat(`mode`)
Pref::floatFormat(NIL)
Pref::floatFormat()
```

## Description

`Pref::floatFormat` controls the output format of floating-point numbers.

The representation mode can be one of the characters `"e"`, `"f"`, `"g"`, `"h"`, or `"x"`. These are the standard `C`-command `printf` switches. Their meaning is:

• "e":

exponential representation (floating-point representation, “scientific format”).

• "f":

decimal representation without exponents.

• "g":

a mix between `"e"` and `"f"`. Numbers x satisfying are displayed without exponents. All other numbers are displayed in floating-point representation.

• "h" or "x":

hexadecimal representation, except for `expr2text` and typesetting, which fall back to `"g"`.

The default value is `"g"`.

`Pref::floatFormat()` returns the current mode without changing it. The call `Pref::floatFormat(NIL)` resets to the default value `"g"`.

## Examples

### Example 1

The exponential representation of a floating-point number consists of its sign, its mantissa and its exponent:

```Pref::floatFormat("e"): 12345.67890, -0.00012345```

Without exponents, the size of a number is indicated by trailing or leading zeroes:

```Pref::floatFormat("f"): 7.0*10^21, 7.0/10^21```

The mixed representation:

```Pref::floatFormat("g"): 1e-10, 9.99e-11```

`2.0^36, 2.0^37`

Hexadecimal display is ignored in typeset output and `expr2text`:

```Pref::floatFormat("h"): 12345.67890, 0.00012345; expr2text(12345.67890, 0.00012345)```

Hexadecimal display is used in the ASCII `print` output:

```PRETTYPRINT := FALSE: print(Plain, 12345.67890, 0.00012345); PRETTYPRINT := TRUE:```
```3.039adcc63f141208@3, 8.1725b672ee34260@-4 ```

The representation is reset to the default mode:

`Pref::floatFormat(NIL):`

## Parameters

 `mode` One of the character strings `"e"`, `"f"`, `"g"`, `"h"`, or `"x"`

## Return Values

Previously defined representation mode