Strange Bug - SUM failing

Vassal 3.5.8
A strange bug (?) in how Expressions and COUNT interacts:

I calculate a dynamic property (WERP) for a counter (StratWar) in one of 2 ways:

a) Subs + 10Flak + FlakFactors + 5Bombers + 3Fighters + [b]0.5V1[/b] + V2 + 4ME262
b) Subs + 10
Flak + FlakFactors + 5Bombers + 3Fighters + V1/2 + V2 + 4*ME262

I display the value via a Text Label (works for both)
a) displays w/ decimal point
b) displays without a decimal point

I then SUM the value of WERP for all counters
a) the SUM does not include the StratWar WERP (I’m guessing because type is REAL)
b) the SUM does include the StratWar WERP (I’m guessing because type is INTEGER)

Should SUM be able to sum reals as well as integers? If yes, then it’s a bug… If no, then the documentation should note it…

It’s interesting that 0.5*A != A/2 and the results (apparently) are typed differently…

That should have been SUM in my post…

“A” and “2” are both integers, so integer division is performed (and the remainder is ignored). You would find if you changed it to “A/2.0” that you would get the same results as “0.5*A”.

VASSAL doesn’t really support real numbers, only integers and strings. This is why the SUM isn’t working correctly if you try to feed it a real number. If those fractions are important and throw off your final sums, the best solution I can come up is to multiply your entire WERP calculation by 2 (and probably call it DoubleWERP or something like that), so you end up with: 2 * (Subs + 10Flak + FlakFactors + 5Bombers + 3Fighters + V2 + 4ME262) + V1

Then, you can SUM DoubleWERP, and divide the final SUM by 2. If the final fraction is important, you might need some extra trickery to check if the sum is odd, and add “.5” to the displayed result if so (or if you want to round up instead of down, just add “1” to the SUM before dividing by 2).

1 Like