Calculation problem

Hi, I’d like to track my strength training progress in Tinderbox, but can’t figure out why this calculation

$MyNumber = ((100 * 50) / (101,3 – (2,67123 * 6)));

yields different results in Tinderbox and other apps.

Result in Tinderbox:

  • 49.5049505

Result in Soulver 3 and CalcBot:

  • 58,6354682195

What am I missing?

Test.tbx (119.1 KB)

Nope.

Then Tinderbox is having problems parsing German notation.

$MyNumber = ((100 * 50) / (101.3 - (2.67123 * 6)));

Does parse to 58.63546822

While, I can confirm that

$MyNumber = ((100 * 50) / (101,3 - (2,67123 * 6)));

Does not

Bug @eastgate ?

1 Like

I’m afraid that Tinderbox actions require “.” as the decimal separator.

Tinderbox inherits this from programming languages such as C, Javascript, LISP, Smalltalk, FORTRAN and ALGOL. This is, I know, a nuisance for everyone accustomed to a different conventions (and, of course, people who use Thai or Burmese numerals).

It’s not simple to support commas as decimal separators because many of these languages (all save Smalltalk and LISP) use commas to separate arguments passed to an operator: ang=atan2(y,x). Tinderbox actions do this too, and so there would be no way to know whether fun(1,5) has one argument or two, unless the delimiter of function parameters was also changed.

Soulver (and also, I presume, CalcBot) don’t need multiple-argument operators, and so can be more lenient in localizing numbers.

Note that the .format() operator in Tinderbox can convert numbers into localized strings, inserting both decimal and thousands separators consistent with the current locale.

Over here this parses to 0.

As 0 is also the atrribute’s default value, I first thought that after merely deleting the old calculation’s result the new calculation doesn’t yield any result. But I double checked it now by manually setting the value to 2. After running the quoted code the value is 0, so the calculation fails over here.

Already tried that before I created the thread but that doesn’t work.

I linted the file, here’s my version. See the last stamp.

Test_2.tbx (94.0 KB)

1 Like

Ahh, although I already tried with more brackets I obviously did it wrong.
Your version works, thanks a lot!

1 Like

Aha! I believe I have located the remaining problem. The extra brackets were a red herring.

In your example,

the symbol that follows 101.3 in not a hyphen. It’s an n-dash. Change it to a hyphen, and change the commas to periods, and all will be well.

$MyNumber = (100 * 50) / (101.3 - (2.67123 * 6));

result: 58.63546822

3 Likes