Project

General

Profile

Bug #4346

Count formatting does not work well with very high numbers

Added by Dark Locq 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Category:
GUI
Target version:
Start date:
03/06/2018
% Done:

100%

Reproducibility:
Always
Operating system:
Other
Severity:
Normal

Description

If I have 1502083 gold, the result displayed is "502k".

I would expect either "1.5m" or, less helpfully, "1502k".

The leading digit is being truncated.

Also, under some circumstances, very incorrect numbers are reported, like "497k" for 1mil. I have no idea what triggers that. The fix is to do something like Player->RemoveItem,"Gold_001",1000000000 to be completely sure it's zeroed out, then add back the proper amount.

When the numbers are badly wrong, it can make NPCs think you don't have enough money for what you're trying to buy; I experienced this in one interaction and was confused by it. I didn't notice the mis-match of actual gold versus displayed amount until much later, which is when I tried the gold removal and re-addition.

Setting this as "Reproducibility: Sometimes" since the wildly wrong numbers problem is not consistent, while the truncation one is; and I picked "OS: MacOS", since that's what I use, though a mechanics and GUI issue like may be cross-platform.

Associated revisions

Revision 60a663ef (diff)
Added by Alexei Dobrohotov 3 months ago

Account for all possible count values in getCountString (Bug #4346)

Revision 3b922d81 (diff)
Added by Alexei Dobrohotov 3 months ago

Don't use floating point arithmetics for formatted count (Bug #4346)

History

#1 Updated by Alexei Dobrohotov 3 months ago

  • Operating system changed from MacOS to Other

Item icon only fits 4 characters reported by getCountString, so the reported 1502k gets truncated to (1)502k. I've submitted a fix so that getCountString accommodates for numbers larger than a million (they get rounded down to the nearest million in this case) and a billion (nearest billion). It does lack precision, but so does rounding down to thousands.

I have no idea how to replicate the second issue.

#2 Updated by Dark Locq 3 months ago

I've submitted a fix so that getCountString accommodates for numbers larger than a million ...

That sounds good.

I have no idea how to replicate the second issue.

Me neither, I was just noting that it happened, in case it comes up again. I tested about a dozen mods that day and don't know which might have been involved (nor what inter-mod conflicts could have been).

#3 Updated by Andrei Kortunov 3 months ago

About second issue, just a guess: there may be a some kind of rounding error, when an engine calculates result of int(count/1000.f), especially when you have a huge amount of gold.
However, this error should not affect trading window since the window uses an exact amount of gold (an integer value) instead of formatted one.

#4 Updated by Andrei Kortunov 3 months ago

For example, if you have a 1502k of gold, a rounding erro can make it a 1497k and trim the leading 1.

#5 Updated by Alexei Dobrohotov 3 months ago

  • Subject changed from Incorrect gold display to Count formatting does not work well with very high numbers
  • Status changed from New to Resolved
  • Assignee set to Alexei Dobrohotov
  • Target version set to openmw-0.44
  • % Done changed from 0 to 100
  • Reproducibility changed from Sometimes to Always

Alright, I think I've figured it out, kudos to Andrei.

#6 Updated by Alexei Dobrohotov 3 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF