Translate

Image of Android Wireless Application Development
Image of Modern Operating Systems (3rd Edition)
Image of Linux Kernel Development (3rd Edition)
Image of XSLT 2.0 and XPath 2.0 Programmer's Reference (Programmer to Programmer)

Convert Integer to Float in Korn Shell

There is no explicit mechanism, such as float(integer), in the Korn Shell (ksh93) to convert an integer to a float which in the Korn Shell is by default a long double. By default, dividing integer 1 by 3 produces 0: $ integer x=1 $ echo $(( x/3 )) 0 $ So how to you get the result, 0.3333 …, which you probably were expecting? You can convert x to floating point and then do the division by replacing the 3 with either 3. or, as I normally do, with 3.0: $ integer x=1 $ echo $(( x/3. )) 0.333333333333333333 $