Author Topic: arithmetic functions bug ($Add, $Sub, etc.)  (Read 689 times)

boroda

  • Sr. Member
  • ****
  • Posts: 4679
US notation for fractional numbers uses dot as decimal point, Russian (and i suspect most European) notation uses comma as decimal point. it's not the problem, when arithmetic functions use tag values, but it may become the problem, when arithmetic functions use explicit literal fractional number as one of operands. if user wants to add 2.5 to <Play Count> (it's just a senseless example to show what i mean), then mb parses corretly:

$Add(<Play Count>, 2,5)

but can't parse correctly:

$Add(2,5,<Play Count>)

and:

$Add(2.5,<Play Count>)

i'm using the following workaround in ATT plugin for mathematical functions:

Code
string CustomFunc_SomeFunction(string number)
{
            char localizedDecimalPoint = (0.5).ToString()[1];
            number = number.Replace('.', localizedDecimalPoint);
            float float_number = float.Parse(number);
            ...
}

so user must always use US notation for explicit literal fractional numbers, and both US or Russian (and European?) notations can be used in tags:

$Add(2.5,<Play Count>)


edit:
also, i remember that there is the entry for decimal point in localization file.
it's entry for list separator, not for decimal point
Last Edit: July 26, 2022, 01:50:28 PM by boroda


boroda

  • Sr. Member
  • ****
  • Posts: 4679