I need to make sure that the value being sent to my contract is at least a certain amount. To do this I need to be able to compare the value with a ufixed:

require(msg.value > previousValue * 1.1)

but I'm getting the following error:

TypeError: Operator > not compatible with types uint256 and ufixed128x18

What's the right way to do this?


2 Answers 2


Using 1100000000000000000 in place of 1.1 should solve your issue, however when scaling values like this, you must make sure that you scale all values accordingly so you don't get weird truncation, or unexpected results.

Useful reading on the subject:

How can I perform float type division in solidity?

Best way to do USD math in Solidity?

  • Thanks! Could you explain why I have to divide the final result by 1 ether please?
    – Taimur
    May 18, 2018 at 18:21
  • Hey sorry I mis-typed, you don't always have to divide the final result by 1 ether you just have to make sure that when you scale one value, you scale all the other values accordingly.
    – hextet
    May 18, 2018 at 18:24
  • Ah okay, thanks. What scaling is being used here? Why does this solve the problem? Know where I can go to read up about this stuff?
    – Taimur
    May 18, 2018 at 18:33
  • The reason you need to scale that value is because the EVM has no usable concept of fixed point integers, nor would you even want to use them. Therefore you need to have a method to handle those values. I personally convert everything "into base of wei". Say for example your number 1.1 to convert that "into base of wei" you can go to a website like this (etherconverter.online), input 1.1 into the ether field, and take the value from the wei field. Or just mulitply your value by 10**18.
    – hextet
    May 18, 2018 at 18:35
  • I'll include some links in my post that will help
    – hextet
    May 18, 2018 at 18:36

Think out of the box:

require(msg.value > previousValue * 11 / 10)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.