calculations in formulas

Discussion related to "Everything" 1.5 Alpha.
Post Reply
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

calculations in formulas

Post by NotNull »

Some observations:

addcol:A A:=round(16)
=> 16,0
addcol:A A:=ROUND(16,0)
=> 16,0 (instead of 16)
addcol:A A:=EVAL(round(16))
=> 160

addcol:A A:=EVAL(1.0*17/99)
=> 171717171 (instead of 0,171717171)
BTW:
/=1.0*17/99
=> 0,171717171


addcol:A A:=EVAL(19/100)
=> 0 (as expected)
addcol:A A:=EVAL(19.0/100)
=> 19

BTW:
/=19/100
=> 0
/=19.0/100
=> 0,19
/=19./100
=> 0,19

Code: Select all

#[define:min=33#]:  addcol:A,B,C  A:=[min:]  C:=8   $C:>$A: B:=N([min:]   nop:"A = min = 33, B= N(min); check if min is numerical, C = 8. Show results if 8>33"

Shows results. Looks like a textual comparison ("8" > "3") instead of a numericla one.


v1386a x64@Win10 22H2
US, not NL this time, although the regional settings for numbers are localized: thousands = "." ; decimals = "'," )
void
Developer
Posts: 17149
Joined: Fri Oct 16, 2009 11:31 pm

Re: calculations in formulas

Post by void »

Thanks for testing ROUND() and EVAL() NotNull,
addcol:A A:=round(16)=> 16,0
addcol:A A:=ROUND(16,0) => 16,0 (instead of 16)
ROUND() returns a double value.
(double is a real number -it has a decimal place)
I have on my TODO list to format the result as a integer value.


addcol:A A:=EVAL(round(16)) => 160
This is caused by ROUND() localizing 16.0 as 16,0
The next update will not localize double numbers when converting them to text.
EVAL() takes a string.
Everything is seeing: EVAL("16,0") => 160


addcol:A A:=EVAL(1.0*17/99) => 171717171 (instead of 0,171717171)
Same issue as above.
Everything is seeing: EVAL("0,171717171")
The next update will not localize double numbers.


addcol:A A:=EVAL(19/100) => 0 (as expected)
Keep in mind, EVAL takes a string.
19/100 will be evaluated by Formulas, converted to a string, then passed to the EVAL() function.
EVAL(19/100) => EVAL(0) => EVAL("0") => 0

EVAL() can be skipped here with:
A:=19/100


addcol:A A:=EVAL(19.0/100) => 19
Everything is incorrectly seeing: EVAL("0,19") => 19


#[define:min=33#]: addcol:A,B,C A:=[min:] C:=8 $C:>$A: B:=N([min:] nop:"A = min = 33, B= N(min); check if min is numerical, C = 8. Show results if 8>33"
Shows results. Looks like a textual comparison ("8" > "3") instead of a numericla one.
Correct, currently custom columns are just text.
Not values.
Support for custom columns values is on my TODO list.
For now, please try:

#[define:min=33#]: eval:8>[min:]
Phlashman
Posts: 45
Joined: Sun Sep 11, 2022 4:57 am

Re: calculations in formulas

Post by Phlashman »

addcol:A A:=EVAL(19.0/100) => 19
Everything is incorrectly seeing: EVAL("0,19") => 19

Should this be dependant, in case of Windows OS, on the regional settings? My settings are that the period, not comma is the decimal separator

EVAL(19.0/100) => EVAL("0.19") => 0.19
void
Developer
Posts: 17149
Joined: Fri Oct 16, 2009 11:31 pm

Re: calculations in formulas

Post by void »

Should this be dependant, in case of Windows OS, on the regional settings?
No, it's an issue with version 1386 and earlier.
It will be addressed in the next alpha update.

Everything will still format your numbers correctly for display using your regional settings.
It just shouldn't be using regional settings when converting numbers to text internally.
void
Developer
Posts: 17149
Joined: Fri Oct 16, 2009 11:31 pm

Re: calculations in formulas

Post by void »

Everything 1.5.0.1387a improves formulas.

Values with no fraction part will be treated as integers.
For example: ROUND(0.5) => 1 (instead of 1.0)



Numbers will no longer be formatted for the current locale unless it's for display.
For example: 0.5 => 0.5 (not 0,5)

Exported numbers will no longer use the current locale.
For example: 0.5 => 0.5 (not 0,5)
Post Reply