[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Stupid newb question



PureBytes Links

Trading Reference Links

Hello,

| is a BIT-WISE OR,
+ is simple addition.

As long as flags you combine are DIFFERENT (like ones in your example)
the result is the same. But generally speaking bitwise OR
is different than addition.

Let me present this on simple 4-bit arithmetic example:

1. Example 1 - when both operators give the same result.

Consider two numbers: 2 and 4.
2 has bitwise representation of 0010
4 has bitwise representation of 0100

Bitwise "OR"  operator (|) returns a one for each bit position where one or both of the corresponding bits of its operands is a one:

a        =  0010
b      = 0100
a | b = 0110

0110 translated to decimal system is 6.

Now we all know that also a + b = 2 + 4 = 6

2. Example 2 - when both operators give different result

Let us now consider 2 + 6 vs 2 | 6.
6 in binary representation is 0110, 2 has binary representation of 0010

a        =  0110
b      = 0010
a | b = 0110

So the result is 0110 and it is 6 (in decimal system).
This is so because bitwise-OR combines bits on single-bit level.
(one for each bit position where one or both of the corresponding bits of its operands is a one)

This time ordinary addition gives 2+6 = 8 which is different.

Generally speaking results of bitwise-OR are the same to the addition
if numbers combined do not have '1' bits on the same bit-position.

This is the case for all style* constants in AB and that's why you can use
+ instead of | for styles. But from "purist" point of view you should use bitwise-OR operator |
to combine binary flags.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Christoper" <turkey@xxxxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, December 09, 2004 1:13 AM
Subject: [amibroker] Stupid newb question


>
>
> When using Plot function (or any function for that matter) and I'm
> putting together the parameters for the plot style...
>
> What's the difference between using | (pipe) versus + (plus)?
>
> as in: styleline+styleownscale vs
> styleline | styleownscale
>
>
>
>
>
>
> Check AmiBroker web page at:
> http://www.amibroker.com/
>
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> Yahoo! Groups Links
>
>
>
>
>
>
>
> 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/