close

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

This formula works as what i wanted:
=IF(B5gt;10000,D5*50%,IF(B5gt;0,D5*25%,\quot;NO TAX\quot;))
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(B5gt;10000,B5*50%,IF(*10000gt;B5gt;0*,B5*25%,quot;No Taxquot;)) *----this
works,displays 1125

*
=IF(B5gt;10000,B5*50%,IF(*0lt;B5lt;10000*,B5*25%,quot;No Taxquot;))* ----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: www.excelforum.com/member.php...oamp;userid=32512
View this thread: www.excelforum.com/showthread...hreadid=522999Hi

If you want more than one test within an IF formula, use AND() or OR(). For
example:
=IF(B5gt;10000,B5*50%,IF(AND(B5gt;0,B5lt;10000),B5*25%,quot; No Taxquot;))

Hope this helps.
Andy.

quot;SFHquot; gt; wrote in message
...
gt;
gt; hi can anyone please explain to me the operator precedence rule in this
gt; formula :
gt;
gt; This formula works as what i wanted:
gt; =IF(B5gt;10000,D5*50%,IF(B5gt;0,D5*25%,\quot;NO TAX\quot;))
gt; The above is the correct formula, my b5=4500, so my answer is 1125. The
gt; formula works.
gt;
gt; but i tried to experiment using the following:
gt;
gt; *=IF(B5gt;10000,B5*50%,IF(*10000gt;B5gt;0*,B5*25%,quot;No Taxquot;)) *----this
gt; works,displays 1125
gt;
gt; *
gt; =IF(B5gt;10000,B5*50%,IF(*0lt;B5lt;10000*,B5*25%,quot;No Taxquot;))* ----this doesn't
gt; work, displays no tax.
gt;
gt; hope someone can explain it to me ..thank you very much. i know this is
gt; something about precedence but i need more details about this.
gt;
gt;
gt; --
gt; SFH
gt; ------------------------------------------------------------------------
gt; SFH's Profile:
gt; www.excelforum.com/member.php...oamp;userid=32512
gt; View this thread: www.excelforum.com/showthread...hreadid=522999
gt;
quot;SFHquot; wrote:
gt; can anyone please explain to me the operator precedence
gt; rule in this formula :
gt; [....]
gt; =IF(B5gt;10000,B5*50%,IF(10000gt;B5gt;0,B5*25%,quot;No Taxquot;))
gt; ----this works,displays 1125
gt; =IF(B5gt;10000,B5*50%,IF(0lt;B5lt;10000*,B5*25%,quot;No Taxquot;))
gt; ----this doesn't work, displays no tax.

Someone else answered the quot;realquot; question, namely: what
is the correct way to express quot;a gt; b gt; cquot;. But to answer your
question ....

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

The second case is evaluated as quot;(0 lt; B5) lt; 10000quot;.
quot;(0 lt; B5)quot; results in true (1) or false (0). So the expression
becomes quot;1 lt; 0quot; or quot;0 lt; 0quot;, which is always false(!).Jumping in to clarify something in joeu's explanation:

10000gt;B5gt;0 is indeed first evaluated as (10000 gt; 85) gt; 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 Truegt;False. Thus:

=1lt;FALSE -------will return TRUE
=FALSElt;TRUE --------- will return TRUE

HTH
Kostis Vezeridesquot;vezeridquot; wrote:
gt; Jumping in to clarify something in joeu's explanation:
gt; 10000gt;B5gt;0 is indeed first evaluated as (10000 gt; 85) gt; 0.
gt; However, the expression in parentheses returns True or
gt; False, not 0 or 1. [....] True and False are considered larger
gt; 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: quot;But note that this does behave as you intended
when B5 lt;= 0.quot; I meant to write: quot;does __not__ behavequot;.
But based on vezerid's comment, quot;(10000 gt; B5) gt; 0quot; does
not even work as you intended when B5 gt;= 10000.
thank you to all of you for clarifying the question i asked. Thanks for
your time and help.

Hana
Singapore--
SFH
------------------------------------------------------------------------
SFH's Profile: www.excelforum.com/member.php...oamp;userid=32512
View this thread: www.excelforum.com/showthread...hreadid=522999

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()