Damage Formula Help

I could use some help with a damage formula. What I have is this:

((((a.atk/2)+P)-(b.def/4))*(((100-b.def)/100)+1)).to_i

Basically, the first half of the formula, (((a.atk/2)+P)-(b.def/4)) is supposed to calculate the base damage. Then, the second half, *(((100-b.def)/100)+1) is supposed to use the target's DEF as a % reduction for the base damage.

P is replaced by a power modifier that I assign to each skill. When I plug this in to my calculator I get a different result than what I am seeing when I test battle. For example:

((((a.atk/2)+5)-(b.def/4))*(((100-b.def)/100)+1)).to_i
((((6/2)+5)-(5/4))*(((100-5)/100)+1)).to_i

In my calculator this come out to be 13. In my test battles this is dealing 7 damage. I have double checked to make sure there aren't any states or elemental effective settings modifying the damage. Is there something really obvious I'm missing?
variation set to 0?
variation set to 0?
Yes, variation is set to 0.

I also tested in a new project to make sure it wasn't a custom script causing a weird effect and I get the same numbers.
Hey,

Ruby (which VXAce uses for its damage formulas) distinguishes between integer and decimal data types (floats). When doing division with integers, the result will also be turned into an integer, rounded down.

You can avoid that by making sure at least one of the operands in each division is a float value.
Constants can be written with a decimal part: (a.atk / 2.0)
Other values can be turned into decimal values by adding to_f: (a.atk.to_f / 2)
Hey,

Ruby (which VXAce uses for its damage formulas) distinguishes between integer and decimal data types (floats). When doing division with integers, the result will also be turned into an integer, rounded down.

You can avoid that by making sure at least one of the operands in each division is a float value.
Constants can be written with a decimal part: (a.atk / 2.0)
Other values can be turned into decimal values by adding to_f: (a.atk.to_f / 2)
Ah, that seems to had solved my issue. Thanks!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-help.166388/