contrast take{ if ((address(this).balance)/100>=1/100){ } }

The code above throws type error: incompatible type between uint256 and rational_const 1/100.does anyone know how to solve that?

  • You should actually consider yourself lucky that it throws this error, because this code is really bad regardless of that. The expression 1/100 would be compiled to 0 in Solidity, since there are no floating-point types (in fact, even in languages which do support floating-point types, this expression as stated would yield zero, since it uses only integers). Jul 7, 2019 at 11:19
  • In any case, here is an idea for you - it seems that you can simply remove the /100 on both sides of the expression. Jul 7, 2019 at 11:21
  • And by the way, what does contrast take followed by an if statement inside curly braces even mean??? Your question is very poorly-phrased! Jul 7, 2019 at 11:22
  • @goodvibration I think it would be nice to be polite especially to new contributors. Jul 7, 2019 at 11:25
  • 1
    @LauriPeltonen: I agree, so I apologize. And I also think that it would be useful not to encourage such low effort in writing a question (encourage by answering such questions) . There are more syntax errors in this question than there are characters, the code is not compilable for several different reasons, and the question in whole doesn't seem to be very contributive (dividing by 100 on both sides???). Jul 7, 2019 at 11:29

1 Answer 1


Solidity doesn't understand fractional numbers and it doesn't support them. In order for it to make the comparison you are doing it would need to store a fractional number at the right hand side and that's not possible.

The obvious solution is to just multiple both side by 100 and therefore it becomes if (address(this).balance >= 1).

Furthermore, as you are comparing Ether balances, keep in mind that 1 as a balance means 1 wei. To be clear you should always write that explicitly so it becomes if (address(this).balance >= 1 wei) Also you have a typo in your code, you should use the keyword contract instead of contrast

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