| Joachim,
Thanks for this clarification. I see better the distinctions between
logical, arithmetic and other operators now.
I suppose that what I was expecting, but csound doesn't provide, is a
boolean data type. This would allow logical computations outside of IF
statements and would allow for storing the result in a variable and
then re-using the computation elsewhere.
But almost the same can be accomplished with bitwise operations.
best,
Lou
On Jan 14, 2010, at 4:55 PM, joachim heintz wrote:
> Hi Lou -
>
> as far as I see the manual is correct in listing || for logical OR,
> because something like
> if 1 > 0 || 2 < 0 then
> print i1+i2
> endif
> is ok. In your example
> k1 = 1
> k2 = 2
> k3 = k1 || k2
> printk2 k3
> k4 = k1 & k2
> printk2 k4,3
> you don't use a boolean expression in combination with ||, so it's
> not working.
> So, at the end, the manual saying
>>>>>>> "Opcodes that perform arithmetic and logic operations are -,
>>>>>>> +, &&,
>>>>>>> ||, *, /, ^, and %."
>>>
> seems to be correct for me, as && and || are logic operations (and
> the others arithmetic).
>
> Or am I missing something? At least I learned something about
> bitwise and / or from the discussion. Best -
>
> joachim
>
>
> Am 13.01.2010 um 21:13 schrieb Louis Cohen:
>
>> Yes, Andres,
>>
>> I made the same test. And I have no problem doing bitwise
>> computations on floating point numbers to achieve my intentions. On
>> small numbers I'm reasonably sure that I won't have to worry about
>> the exponent portion of two floating point numbers being different.
>>
>> However, the manual for some reason lists || for logical OR, not |.
>> And yet csound treats || as an error but handles | as you
>> indicated. Since I don't speak C (but I do speak Java) I was
>> wondering if I missed something. From what everyone is saying, it
>> seems it's just an error in the manual that for some reason hasn't
>> bothered anyone.
>>
>> -Lou
>>
>> On Jan 13, 2010, at 2:52 PM, Andres Cabrera wrote:
>>
>>> Hi,
>>>
>>> Just checking it now, Csound does bitwise operations on integers.
>>> See:
>>>
>>>
>>>
>>>
>>>
>>>
>>> instr 1
>>> iresultOr = p4 | p5
>>> iresultAnd = p4 & p5
>>> prints "%i | %i = %i\\n", p4, p5, iresultOr
>>> prints "%i & %i = %i\\n", p4, p5, iresultAnd
>>> endin
>>>
>>>
>>>
>>> i 1 0 0.1 1 2
>>> i 1 + . 1 3
>>> i 1 + . 2 4
>>> i 1 + . 3 10
>>> e
>>>
>>>
>>>
>>> Cheers,
>>> Andrés
>>>
>>> On Wed, Jan 13, 2010 at 7:42 PM, Michael Gogins
>>> wrote:
>>>> I don't know, sorry.
>>>>
>>>> Bitwise would still work with floating point numbers, since they
>>>> are
>>>> after all made of bits. But I suspect that Csound uses | for
>>>> logical
>>>> OR.
>>>>
>>>> Regards,
>>>> Mike
>>>>
>>>> On 1/13/10, Louis Cohen wrote:
>>>>> Thanks, Mike,
>>>>>
>>>>> Your answer, together with the statement in the manual:
>>>>>
>>>>>>> "Opcodes that perform arithmetic and logic operations are -,
>>>>>>> +, &&,
>>>>>>> ||, *, /, ^, and %."
>>>>>>>
>>>>>
>>>>> ...suggests that I can compute boolean expressions in csound,
>>>>> since,
>>>>> as you said, || is a logical OR, while | is a binary OR. But I was
>>>>> under the impression that csound used only one computational type:
>>>>> floating point.
>>>>>
>>>>> Further, the manual doesn't mention the single-bar version as
>>>>> far as I
>>>>> can tell, only the double-bar version (as in the above quotation.)
>>>>>
>>>>> Is the statement I quoted above just an error? (Same comments
>>>>> for &&
>>>>> and &, I suppose...)
>>>>>
>>>>> -Lou
>>>>>
>>>>>
>>>>> On Jan 13, 2010, at 12:57 PM, Michael Gogins wrote:
>>>>>
>>>>>> In languages with C syntax, | is bitwise OR where
>>>>>>
>>>>>> binary 01 OR 10 -> binary 11
>>>>>>
>>>>>> and || is local OR where
>>>>>>
>>>>>> binary 01 OR 10 -> logical TRUE, any non-zero value, usually1
>>>>>> or -1.
>>>>>>
>>>>>> Hope this helps,
>>>>>> Mike
>>>>>>
>>>>>> On 1/13/10, Louis Cohen wrote:
>>>>>>> Hi, everyone,
>>>>>>>
>>>>>>> I had a need for performing a bit-wise OR operation today and
>>>>>>> checked
>>>>>>> the manual for the proper notation. The Manual says:
>>>>>>>
>>>>>>> "Opcodes that perform arithmetic and logic operations are -,
>>>>>>> +, &&,
>>>>>>> ||, *, /, ^, and %."
>>>>>>>
>>>>>>> The double vertical bar is apparently the symbol for logical
>>>>>>> OR, but
>>>>>>> when I use it I get an error. After much trial-and-error, I
>>>>>>> found the
>>>>>>> a single vertical bar gets accepted by Csound version 5.09
>>>>>>> (float
>>>>>>> samples) Sep 22 2008, and appears to give me the expected
>>>>>>> result (1 |
>>>>>>> 2 gives 3)
>>>>>>>
>>>>>>> So how come the manual shows this as a double bar?
>>>>>>>
>>>>>>> ALSO, what's going on under the hood? I thought numerical
>>>>>>> values were
>>>>>>> floating point (in the floating point version.) If so, can I
>>>>>>> still
>>>>>>> safely use bit-wise computations for numbers up to, say 256? or
>>>>>>> 65565?
>>>>>>>
>>>>>>> thanks, and Happy New Year!
>>>>>>>
>>>>>>> -Lou
>>>>>>>
>>>>>>>
>>>>>>> Send bugs reports to this list.
>>>>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>>>>> "unsubscribe
>>>>>>> csound"
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Michael Gogins
>>>>>> Irreducible Productions
>>>>>> http://www.michael-gogins.com
>>>>>> Michael dot Gogins at gmail dot com
>>>>>>
>>>>>>
>>>>>> Send bugs reports to this list.
>>>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>>>> "unsubscribe csound"
>>>>>
>>>>>
>>>>>
>>>>> Send bugs reports to this list.
>>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>>> "unsubscribe
>>>>> csound"
>>>>>
>>>>
>>>>
>>>> --
>>>> Michael Gogins
>>>> Irreducible Productions
>>>> http://www.michael-gogins.com
>>>> Michael dot Gogins at gmail dot com
>>>>
>>>>
>>>> Send bugs reports to this list.
>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>>> "unsubscribe csound"
>>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>> Andrés
>>>
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>>> "unsubscribe csound"
>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> "unsubscribe csound"
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body
> "unsubscribe csound"
Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |