# convert fraction to decimal in org spreadsheet

How do I convert 1:6 into 0.166666 using the org spreadsheet?

I was thinking it should be `\$4=\$3;%f` but it's clearly not.

``````| x | y |   z |        f |
|---+---+-----+----------|
| 1 | 1 |   1 | 1.000000 |
| 1 | 2 | 1:2 | 1.000000 |
| 1 | 3 | 1:3 | 1.000000 |
| 1 | 6 | 1:6 | 1.000000 |
#+TBLFM: \$3=\$1/\$2;F::\$4=\$3;%f
``````

Just multiply with a float:

``````| x | y |   z |          f |
|---+---+-----+------------|
| 1 | 1 |   1 |         1. |
| 1 | 2 | 1:2 |        0.5 |
| 1 | 3 | 1:3 | 0.33333333 |
| 1 | 6 | 1:6 | 0.16666667 |
#+TBLFM: \$3=\$1/\$2;F::\$4=\$3*1.
``````

Since division is multiplication with inverse, you could skip the extra step:

``````| x | y |   z |          f |            |
|---+---+-----+------------+------------|
| 1 | 1 |   1 |          1 |         1. |
| 1 | 2 | 1:2 |        0.5 |        0.5 |
| 1 | 3 | 1:3 | 0.33333333 | 0.33333333 |
| 1 | 6 | 1:6 | 0.16666667 | 0.16666667 |
#+TBLFM: \$3=\$1/\$2;F::\$4=\$1*inv(\$2)::\$5=float(\$1/\$2)
``````

Another way would be to simply convert the rational result to float. Also notice how in the first case Calc will create nicer (subjectively) output: wherever the result is a whole number, it will be an integer rather than a float (this may be important due to possible rounding errors with floats).

• +1 for `float()`. The `inv()` trick, on the other hand, seems completely unhelpful to me. When writing an Org table formula (or any code, for that matter) I want to avoid duplication. The approach using `float()` allows one to update only one place if the formula for column 3 changes, while the `inv()` trick requires updating two formulas instead of one. Dec 10 '14 at 22:18