help with subtraction (Page 1) ● SmileBASIC Source Forums

Register

# help with subtraction

• #1 ✎ 3 Plisken So I was making this RPG pokemon type fighting example (I unfortunately don't have it anymore, I think I lost it during a transfer) But I remember having a problem with subtraction. If the amount being subtracted was a single digit number, it would do just fine. but If it had more then one digit like 10 or 13, it would return with a decimal. So how do I prevent this from happening? (the calculations were for health BTW) Posted
• #2 ✎ 167 Mariominer First Day Joined on the very first day of SmileBASIC Source Website Promoted Page My page was promoted on SmileBASIC Source! Achievements Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength I don't understand how that happens... What code are you using? Because there shouldn't be much of a problem if you're doing something like this: ```ATK = whatever HP = HP - ATK``` Posted
• #3 ✎ 3 Plisken
I don't understand how that happens... What code are you using? Because there shouldn't be much of a problem if you're doing something like this: ```ATK = whatever HP = HP - ATK```
It was so long ago I can't even remember how it was coded. I was thinking maybe I was making a simple mistake that might be common. I'm pretty sure it was similar to what you posted though. I eventually just made the max health 9 because of this problem but it's been bugging me ever since.
Posted
• #4 ✎ 99 kitesinpowerlines Avatar Block I didn't change my avatar for 30 days. Website Avatar Embargo I didn't change my avatar for 90 days Website Avatar Taboo I didn't change my avatar for 180 days Website Well, I am not sure what it could have been but if it happens again or you want to troubleshoot that section of code you could try `HP = ROUND(HP-ATK)` This would round to the nearest whole number. Posted
• #5 ✎ 3 Plisken
Well, I am not sure what it could have been but if it happens again or you want to troubleshoot that section of code you could try `HP = ROUND(HP-ATK)` This would round to the nearest whole number.
Ok thanks. That should help
Posted