Solidity Data Types – Understanding Fixed and Ufixed Data Types in Solidity

solidity

Can somebody explain what are the fixed and ufixed data types in Solidity. Can you give me some examples?

I expected that these are the representations of decimal numbers, but this is not a case?

Thank you for your answers!

Best Answer

According to the docs: http://solidity.readthedocs.io/en/latest/types.html#fixed-point-numbers

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

So to answer your question, they exist, but you can't use them yet.

When they become supported, you'll be able to use them to represent a number with a fixed number of decimal places.

A side note, I found this question, because I need to store a dollar value in my contract. It seems as though I will either have to store cents as a uint or just use a string... probably going with cents, so that I can easily perform operations... Not sure if that helps you.

Related Topic