float

Official Description

Declares a variable as floating-point storage (allows a decimal point).

Syntax

float [variable[=value]]

Options

None

Oddities

Not available prior to ksh93.

float is an alias for typeset -E.

Example

$ float                      # No floats declared yet
$
$ float hourly=4.98          # Declare hourly as a float
$
$ float                      # Displays current floats
hourly=4.98
$
$ hourly=hourly+2            # Can do float arithmetic
$
$ print $hourly              # Display result
6.98
$
				

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.