[Ethereum] How to perform float type division in solidity

solidity

How can I achieve proper division of two integers in solidity?

Suppose I perform : 3/2 the solution provided is 1 and not 1.5

please help.

Best Answer

The Fixed Point Numbers documentation has a warning which says:

Fixed point numbers are not fully supported by Solidity yet. They can be declared, but cannot be assigned to or from.

The warning at the bottom of Rational and Integer Literals says:

Division on integer literals used to truncate in earlier versions, but it will now convert into a rational number, i.e. 5 / 2 is not equal to 2, but to 2.5