Re: [libreoffice-users] Help with the CALC CURRENT() function

2016-01-04 Thread Brian Barker

At 15:36 03/01/2016 -0500, Rémy Gauthier wrote:
I am using CALC in LO 5.0.3.2 on a Fedora 23 
(formally 22) system. The version of LO I use is 
a version I downloaded from the LO site, not the 
version that installs with Fedora. I had to 
implement something in CALC that looked more or less like this:

F(X) = (X+5)*6 + (((25+(X+5)*6-6) MOD 14)

If X is equal to 25, the result is 183. If I 
place this formula in a cell (where cell A2 
contains 25): =(A2+5)*6+MOD(25+(A2+5)*6-6;14), 
CALC indeed provides 183 as the answer. However, 
the following thing happens when I try to use 
the CURRENT() function in that calculation:


=(A2+5)*6+MOD(25+CURRENT()-6;14): The result provided is 182
=(A2+5)*6+MOD(25-6+CURRENT();14): The result provided is 190
=(A2+5)*6+MOD(CURRENT()+25-6;14): The result provided is 183
=(A2+5)*6+MOD(-6+CURRENT()+25;14): The result provided is 193

It is my understanding that the CURRENT() 
function returns the current value of the 
formula being calculated. In the examples above, 
because the call to CURRENT() is inside the 
MOD(), the value of the formula at that point 
should be the same (180=(25+5)*6 in my example) 
regardless of where CURRENT() is placed since 
the MOD cannot be calculated before the two 
arguments are evaluated. Is there something I am missing?


I suspect this is "by design". The problem, I 
think, is that there is no unique meaning to "the 
current value of the formula being calculated" in 
any but the simplest of cases. If your formula is 
evaluated from left to right, the first part will 
indeed have been determined as 180. But then this 
result will have been held in suspension whilst 
the value of the MOD() function reference - and 
in particular of its first argument - is 
calculated. In your first example, for instance, 
when CURRENT() is encountered, there will be two 
current values, neither of which can be described 
as the value of the formula, namely the 180 and 
now 25 as part of the new calculation. CURRENT() 
clearly uses this new value - the value of the 
sub-expression currently being evaluated - and not the value in suspension.


In the third example, there is no value yet for 
the new sub-expression, and CURRENT() defaults to 
the existing value of 180. I think you like this, 
but I'm not sure it's helpful. You might be amused by examining the effect of

=MOD(CURRENT()+25-6;14)
or just
=CURRENT()

I suspect you need either not to worry about the 
extra calculation done if you repeat (A2+5)*6 
explicitly within your formula or else to 
calculate it separately in a cell and then use a 
reference to that cell twice in your formula. 
Remember that the necessary cell can be in a 
hidden column or row or outside the print range 
or on another sheet, as preferred. CURRENT() is meant for other purposes.


I trust this helps.

Brian Barker


--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted



[libreoffice-users] Help with the CALC CURRENT() function

2016-01-03 Thread Remy Gauthier
Hi,

I am using CALC in LO 5.0.3.2 on a Fedora 23  (formally 22) system. The
version of LO I use is a version I downloaded from the LO site, not the
version that installs with Fedora.

I had to implement something in CALC that looked more or less like
this:

F(X) = (X+5)*6 + (((25+(X+5)*6-6) MOD 14)

If X is equal to 25, the result is 183. If I place this formula in a
cell (where cell A2 contains 25): =(A2+5)*6+MOD(25+(A2+5)*6-6;14), CALC
indeed provides 183 as the answer. However, the following thing happens
when I try to use the CURRENT() function in that calculation:

=(A2+5)*6+MOD(25+CURRENT()-6;14): The result provided is 182
=(A2+5)*6+MOD(25-6+CURRENT();14): The result provided is 190
=(A2+5)*6+MOD(CURRENT()+25-6;14): The result provided is 183
=(A2+5)*6+MOD(-6+CURRENT()+25;14): The result provided is 193

It is my understanding that the CURRENT() function returns the current
value of the formula being calculated. In the examples above, because
the call to CURRENT() is inside the MOD(), the value of the formula at
that point should be the same (180=(25+5)*6 in my example) regardless
of where CURRENT() is placed since the MOD cannot be calculated before
the two arguments are evaluated.

Is there something I am missing?

Thanking you in advance for any insights/information about this.

Rémy Gauthier.


-- 
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted