Dividing 1 with 3 causing problems

I have attributes in my game represented by numbers. In this context, let’s say enemy Agility is 5(five). Whenever I attack, depending on hit score, Agility gets 1 cut which is 1/3 damage at the lowest hit score. 3 Cuts create a wound, dropping the total Agility from 5 to 4. At least it should be.

I’m using FLOAT, which always truncates the result which makes it INTEGER, meaning with 1 or 2 cuts(1/3 and 2/3 respectively) drops 5 to 4 in the calculation, which shows in the UI accordingly.

Whenever I create 3 cuts with one hit, meaning 1 wound, it drops from 5 to 4.
If I create 1 cut first, then 2 cuts in one hit after that turn it totals up to 3 cuts, meaning 1 wound, again it drops from 5 to 4.
But if I create 2 cuts first, then 1 cut after that turn it totals up to 3 cuts, meaning 1 wound, but this time, it drops from 5 to 3

The weird thing is, in the debugger, the result is always 4 in those three situations I presented.

I tried multiplying everything with 1000 to get over fractional numbers, it does the same thing.

I find out that TRUNCATE causing this problem, but why?

So my question is, how can (1/3)x3 result more than 1? I didn’t have any prior coding knowledge before I delved into Blueprints so right now I only know logic in game development. This mathematical situation puzzles me.

Thanks in advance.

Assuming You want to deduct 1 Point for each 3 Cuts Or Wounds (Like for the First 3 the Agility Drops From 5 to 4; Then for Next 3 cuts from 4 to 3 and so on)_

Do One thing Update Mechanics such as instead of deducting 1/3… Store the first and Second Cut (You can Use Bool, Gate, int var etc) on the Third Cut Simple Deduct the Value i.e 1

And The Fresh value is to Be Stored Back (Set_Agility after deduction) So the Fresh value is now 4 reapeat the Process…

ps- Better Cut(dont Delete untill new method works out for ya) all the nodes and Drag them aside…

Correct me If My Assumption is Wrong

So you are saying I shouldn’t drop any numbers with 1/3 but count the cuts(1/3s) and when it reaches the exact count of 3 cuts I should then calculate -1 to that attribute?

It’s a good solution. Thank you.

But without tackling this with a great solution of yours, why is this happening? Do you have any knowledge of this. Is it a calculation problem? Or 0.33333333333… always causing problems in coding?

1/3 doesn’t have a real product(i.e. integer)
it keeps on going .33333…
if you do 1/2 or 1/4 it may still work

but I guess three cut is a good number so For that Use the Method There might be more work around Enjoy Exploring!!

Thank you so much for the reply and the new route for my logic. I’ll keep here posted after I finish this workaround.

Have a great day!