# Talk:Damage calculation

Re: Notation
It's been several years since I took any programming classes so I might be misunderstanding something, but for the
are you sure you mean "round toward infinity" and not "round away from zero"? I thought "round toward infinity" *was* ceil; and intuitively, rounding -1.5 toward positive infinity gives -1, not -2. Rounding -1.5 to -2 is "round away from zero," which would make more sense with the given definition of truncation as "round toward zero."

- As linked to in the (slightly messy) Notation section, https://en.wikipedia.org/wiki/Rounding#Rounding_to_integer describes the differences between the different roundings. I've replaced all occurrences of "round-toward-infinity" with "round-away-from-zero", as these are the same thing - but this wording hopefully is less confusing.
- Saschb (talk) 22:33, 15 May 2017 (UTC)

## Re: Specials[edit source]

I was under the impression that specials in the Chilling Wind, Glowing Ember, and Retribution families added flat damage to the attack that was not subject to mitigation from Defense or Resistance.

With the new variable for these types of specials (and Wo Dao), ExtraDmg, the resulting damage equation would look something like: (Max([Atk*Eff]*[1±Adv] + [SpcStat*SpcMod] - Mit*[1+MitMod], 0) + ExtraDmg) * ClassMod * [1-OffMult] * [1-DefMult]

The Max() function takes the greater value between two values (the normal damage calculated up to the point of the target's normal mitigation, and zero), preventing you from dealing less than zero damage.

Is this not correct?

Also, for the round towards 0 or infinity notation, I noticed that every example listed on this page gives the same result by simply truncating the final value when no rounding is performed midway through the operation, and as a software developer, I think that it is incredibly likely that they are probably using floating point arithmetic and then casting/converting to integer at the end, which results in truncation. Are there any examples you can provide where this does not occur and the more complicated rounding scheme is proven?

- First, the max(x,0) notation was used initially, but was removed to prevent clutter. It is now replaced by the
`Note: Mit can never reduce the damage value to below zero, in a situation where a negative value would be produced, zero is used instead.`

, which is meant to provide the same function. - Second, truncating is the same operation as "round-towards-zero", so there's no complicated rounding scheme. It is also what I suspect they're doing in the code.
- Basically, what you're saying is correct, but it is also what the page is saying, so I don't understand your concern. The only thing I think you're wrong about is that the stat based specials (Chilling Wind, Glowing Ember, etc.) add flat damage - which they don't. They are added in the SpcStat part, as in the formula you provided.
- Saschb (talk) 21:41, 22 August 2017 (UTC)

Have to write something here or the system won't let me revert an edit I made with faulty assumptions. 173.79.191.238 22:15, 28 February 2019 (UTC)

## Rounding[edit source]

Do we have any proof that *all* of these roundings applies? --Ale1991 (talk) 00:23, 23 June 2018 (UTC)

- I have never seen a situation in the game that uses round up or round down instead of truncation. Some confusion might result in the order the game does something, but it is always truncation, I think. For example, To get total attack after weapon-triangle disadvantage people might multiply for short, but the description says Atk-20%, so the correct formula would be . Please let me know if I am wrong. Endilyn (talk) 01:45, 23 June 2018 (UTC)
- Reading some of this page again, it seems it makes this mistake also, using for Buckler instead of (although they still result in the same answer). Endilyn (talk) 01:52, 23 June 2018 (UTC)
- It's possible that the game uses floating point variables and then visualizes the numbers truncated/rounded? --Ale1991 (talk) 17:49, 2 July 2018 (UTC)
- No it is not possible, C & A: Bound Hero Battle example:

Result in video: 10 damage.

You might think that it is because the the final numbers are rounded besides truncated, however this is not the case either. Another example:

Result in video: 28 damage to Robin. Endilyn (talk) 18:26, 2 July 2018 (UTC)

## trunc[edit source]

Could we use a less cumbersome notation for truncation? I find nothing on internet about a specific character for trunc, maybe ⌊x⌉ can be used --Ale1991 (talk) 16:10, 23 September 2018 (UTC)