Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
SFH
 
Posts: n/a
Default Need explanation on operator precedence


hi can anyone please explain to me the operator precedence rule in this
formula :

This formula works as what i wanted:
=IF(B510000,D5*50%,IF(B50,D5*25%,\"NO TAX\"))
The above is the correct formula, my b5=4500, so my answer is 1125. The
formula works.

but i tried to experiment using the following:

*=IF(B510000,B5*50%,IF(*10000B50*,B5*25%,"No Tax")) *----this
works,displays 1125

*
=IF(B510000,B5*50%,IF(*0<B5<10000*,B5*25%,"No Tax"))* ----this doesn't
work, displays no tax.

hope someone can explain it to me ..thank you very much. i know this is
something about precedence but i need more details about this.


--
SFH
------------------------------------------------------------------------
SFH's Profile: http://www.excelforum.com/member.php...o&userid=32512
View this thread: http://www.excelforum.com/showthread...hreadid=522999

  #2   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Need explanation on operator precedence

Hi

If you want more than one test within an IF formula, use AND() or OR(). For
example:
=IF(B510000,B5*50%,IF(AND(B50,B5<10000),B5*25%," No Tax"))

Hope this helps.
Andy.

"SFH" wrote in message
...

hi can anyone please explain to me the operator precedence rule in this
formula :

This formula works as what i wanted:
=IF(B510000,D5*50%,IF(B50,D5*25%,\"NO TAX\"))
The above is the correct formula, my b5=4500, so my answer is 1125. The
formula works.

but i tried to experiment using the following:

*=IF(B510000,B5*50%,IF(*10000B50*,B5*25%,"No Tax")) *----this
works,displays 1125

*
=IF(B510000,B5*50%,IF(*0<B5<10000*,B5*25%,"No Tax"))* ----this doesn't
work, displays no tax.

hope someone can explain it to me ..thank you very much. i know this is
something about precedence but i need more details about this.


--
SFH
------------------------------------------------------------------------
SFH's Profile:
http://www.excelforum.com/member.php...o&userid=32512
View this thread: http://www.excelforum.com/showthread...hreadid=522999



  #3   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Need explanation on operator precedence

"SFH" wrote:
can anyone please explain to me the operator precedence
rule in this formula :
[....]
=IF(B510000,B5*50%,IF(10000B50,B5*25%,"No Tax"))
----this works,displays 1125
=IF(B510000,B5*50%,IF(0<B5<10000*,B5*25%,"No Tax"))
----this doesn't work, displays no tax.


Someone else answered the "real" question, namely: what
is the correct way to express "a b c". But to answer your
question ....

The first case is evaluated as "(10000 B5) 0".
"(10000 B5)" results in a boolean value of true or false,
which has a numerical value of 1 or 0 respectively. Therefore,
the expression becomes "1 0" or "0 0", which coincidentally
is true or false when "(10000 B5)" is true or false. But note
that this does behave as you intended when B5 <= 0. In that
case "10000 B5 0" will be true(!).

The second case is evaluated as "(0 < B5) < 10000".
"(0 < B5)" results in true (1) or false (0). So the expression
becomes "1 < 0" or "0 < 0", which is always false(!).

  #4   Report Post  
Posted to microsoft.public.excel.misc
vezerid
 
Posts: n/a
Default Need explanation on operator precedence

Jumping in to clarify something in joeu's explanation:

10000B50 is indeed first evaluated as (10000 85) 0. However, the
expression in parentheses returns True or False, not 0 or 1. Thus, the
final evaluation compares a T/F with a 1/0.

Excel here provides a two-faced behavior: In *arithetic* expressions,
True is implicitly converted to 1 and False is converted to 0. Yet,
when doing explicit comparison, i.e. in *logical* expressions, True and
False are considered larger than any number and TrueFalse. Thus:

=1<FALSE -------will return TRUE
=FALSE<TRUE --------- will return TRUE

HTH
Kostis Vezerides

  #5   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Need explanation on operator precedence

"vezerid" wrote:
Jumping in to clarify something in joeu's explanation:
10000B50 is indeed first evaluated as (10000 85) 0.
However, the expression in parentheses returns True or
False, not 0 or 1. [....] True and False are considered larger
than any number


Thanks for the correction. I admit that I am used to a
reasonable language like C, and I ass-u-me-d that Excel
followed suit.

It's a moot point now, but another comment to correct ....
I wrote: "But note that this does behave as you intended
when B5 <= 0." I meant to write: "does __not__ behave".
But based on vezerid's comment, "(10000 B5) 0" does
not even work as you intended when B5 = 10000.



  #6   Report Post  
Posted to microsoft.public.excel.misc
SFH
 
Posts: n/a
Default Need explanation on operator precedence


thank you to all of you for clarifying the question i asked. Thanks for
your time and help.

Hana
Singapore


--
SFH
------------------------------------------------------------------------
SFH's Profile: http://www.excelforum.com/member.php...o&userid=32512
View this thread: http://www.excelforum.com/showthread...hreadid=522999

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
explanation of various fields on financial templates alvn1 New Users to Excel 3 March 15th 06 05:56 PM
Counting or Total Formulas -- Further Explanation MAB Excel Worksheet Functions 3 January 13th 06 05:56 PM
Has anyone had formulas change automatically with no explanation? DavidA3878 Excel Worksheet Functions 1 November 2nd 05 12:42 AM
Can I make pop up explanation boxes in Excel Explanation boxes Excel Discussion (Misc queries) 1 July 20th 05 06:05 AM
Explanation for Excel message "no more fonts may be applied"? Ralph Coomber Excel Discussion (Misc queries) 1 May 5th 05 12:49 PM


All times are GMT +1. The time now is 11:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"