Reputation: 2320
To learn a bit about ethereum, I thought I'd code up a simple loan contract. I added a few simple properties for any loan, and I immediately ran into problems.
contract Loan
{
address lender;
address borrower;
uint amount;
???? interestRate;
...
}
What type do I use for the interest rate? Looking at the solidity types documentation, the primitive types include Boolean and multiple kinds of integers. There is no primitive for decimal numbers.
Without decimal numbers, how do I calculate the interest?
Upvotes: 1
Views: 4062
Reputation: 2320
The Solidity changelog shows that fixed point types will be included in version 0.3.0 which is in development.
Upvotes: 1
Reputation: 773
You can use another unit. Like multiply every percentage by 100, you achieve a 2 number after comma precision
1% => 100
0,1% => 10
0,01% => 1
If it's not enough, you can use other multipliers.
Upvotes: 3