Help with a damage formula

I'm trying to make a damage formula that increases the base damage by 0.5 for every 1% of HP lost. I've been running with the following equation, which I've tested in Python:
Code:
((120*(a.atk / b.def))+((120*(a.atk / b.def))*((a.mhp-a.hp)/a.mhp)*0.5));
Now, the issue is that it only returns 120 every time. I've realized the issue lies in the
Code:
((a.mhp-a.hp)/a.mhp)
As it only returns 0. Anything I can do?
(Also, I am aware of Yanfly Lunatic and that it has a script for this. However, that requires Lunatic damage and, considering the amount of scripts I have that interact with the damage formula box, I don't want to potentially do more damage control for just one move.
I've been running with the following equation, which I've tested in Python:
RPG Maker VX Ace uses Ruby.

I've realized the issue lies in the
Code:
((a.mhp-a.hp)/a.mhp)
As it only returns 0. Anything I can do?
Ruby automatically converts division between integers into an integer result. You'd have to cast those into decimal values.

You can instead use the built in a.hp_rate method.

As a side tip, it's not hurting anything but it might improve readability and reduce chances of error to not have as many superfluous parentheses.
Is there any way I can return the rate of HP lost rather than the current HP rate?
Is there any way I can return the rate of HP lost rather than the current HP rate?
subtract the hp rate from 1 to get the lost hp rate
I knew it was some elementary school stuff. Here I was trying to do algebra to find something lol.
Thanks a bunch! It all works nicely!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-a-damage-formula.173075/