Veketti
Full Member level 3
- Joined
- Sep 14, 2014
- Messages
- 164
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 16
- Activity points
- 1,700
Dear All,
I'm struggling to get numbers with decimals in MicroC pro without using floating point numbers. Eg. I have numbers from -500 to +500 and I need to get that shown in lcd display like "5.00". Naturally I'd do it like making it float, dividing by 100 and floattostr, but MicroC says, Aaaarrggggghhh, too complicated, I give up.:thumbsdown: "There's not enough rom space"
So I am thinking that probably it should be done so that get that number in string array and move all the numbers from right one slot left and add point there. eg. "500" -> "5 00" -> "5.00". But then it would need to work for numbers like 1 also. So it would have to add zeros like "1" -> "0.01". I don't know how to do this. There has to be some easier way which might be obvious and I'm not aware so please help me?
I'm struggling to get numbers with decimals in MicroC pro without using floating point numbers. Eg. I have numbers from -500 to +500 and I need to get that shown in lcd display like "5.00". Naturally I'd do it like making it float, dividing by 100 and floattostr, but MicroC says, Aaaarrggggghhh, too complicated, I give up.:thumbsdown: "There's not enough rom space"
So I am thinking that probably it should be done so that get that number in string array and move all the numbers from right one slot left and add point there. eg. "500" -> "5 00" -> "5.00". But then it would need to work for numbers like 1 also. So it would have to add zeros like "1" -> "0.01". I don't know how to do this. There has to be some easier way which might be obvious and I'm not aware so please help me?