[Csnd] conditionals, program flow ternary form question
| Date | 2019-10-01 20:48 |
| From | pablozoani |
| Subject | [Csnd] conditionals, program flow ternary form question |
Hello developers, the following code prints to console two lines of "division
by zero" while i expected the divisions to be skipped if value2 == 0. Is
this the normal behavior? Using Csound version:6130 Precision:double
(64-bit) win10
input
output
Regards
--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |
| Date | 2019-10-01 20:51 |
| From | pablozoani |
| Subject | Re: [Csnd] conditionals, program flow ternary form question |
(raw text option of forum didn't work)
input
instr 1
i_value = 0
i_value2 = 0
i_value = (i_value2 == 0) ? i_value :\
(i_value < 0) ? (1 / floor(i_value)) :\
(i_value > 0) ? (1 / ceil(i_value)) : 0
print i_value
endin
output
SECTION 1:
new alloc for instr 1:
WARNING: Division by zero
WARNING: Division by zero
instr 1: i_value = 0.000
--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |
| Date | 2019-10-01 21:12 |
| From | john |
| Subject | Re: [Csnd] conditionals, program flow ternary form question |
Yes looks like a major generic bug in a?b:c
Will take a look later but with -v option one can see it generates dubious
code
=.i args: i_value 0
=.i args: i_value2 0
== args: #b0 i_value2 0
< args: #b1 i_value 0
floor.i args: #i2 i_value
##div.ii args: #i3 1 #i2
> args: #b4 i_value 0
ceil.i args: #i5 i_value
##div.ii args: #i6 1 #i5
:cond.i args: #i7 #b4 #i6 0
:cond.i args: #i8 #b1 #i3 #i7
:cond.i args: i_value #b0 i_value #i8
print args: i_value
==John ff
On Tue, 1 Oct 2019, pablozoani wrote:
> Hello developers, the following code prints to console two lines of "division
> by zero" while i expected the divisions to be skipped if value2 == 0. Is
> this the normal behavior?
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |
| Date | 2019-10-03 23:41 |
| From | Pablo Zoani Heffele |
| Subject | Re: [Csnd] conditionals, program flow ternary form question |
|
Thanks for replying John. By the way, non ternary form works as expected. Regards
De: A discussion list for users of Csound <CSOUND@LISTSERV.HEANET.IE> en nombre de john <jpff@CODEMIST.CO.UK>
Enviado: martes, 1 de octubre de 2019 17:12 Para: CSOUND@LISTSERV.HEANET.IE Asunto: Re: [Csnd] conditionals, program flow ternary form question Yes looks like a major generic bug in a?b:c
Will take a look later but with -v option one can see it generates dubious code =.i args: i_value 0 =.i args: i_value2 0 == args: #b0 i_value2 0 < args: #b1 i_value 0 floor.i args: #i2 i_value ##div.ii args: #i3 1 #i2 > args: #b4 i_value 0 ceil.i args: #i5 i_value ##div.ii args: #i6 1 #i5 :cond.i args: #i7 #b4 #i6 0 :cond.i args: #i8 #b1 #i3 #i7 :cond.i args: i_value #b0 i_value #i8 print args: i_value ==John ff On Tue, 1 Oct 2019, pablozoani wrote: > Hello developers, the following code prints to console two lines of "division > by zero" while i expected the divisions to be skipped if value2 == 0. Is > this the normal behavior? Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
| Date | 2019-10-04 13:06 |
| From | john |
| Subject | Re: [Csnd] conditionals, program flow ternary form question |
I am working on a fix. Unfortunately this is a complex area of code and
it is taking a lot og time.
==John
On Thu, 3 Oct 2019, Pablo Zoani Heffele wrote:
> Thanks for replying John. By the way, non ternary form works as expected.
> Regards
>
> Obtener Outlook para Android
>
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |
| Date | 2019-10-08 16:01 |
| From | john |
| Subject | Re: [Csnd] conditionals, program flow ternary form question |
Fixed in github just now. Sorry it took so long
On Tue, 1 Oct 2019, pablozoani wrote:
> (raw text option of forum didn't work)
>
> input
>
> instr 1
> i_value = 0
> i_value2 = 0
>
> i_value = (i_value2 == 0) ? i_value :\
> (i_value < 0) ? (1 / floor(i_value)) :\
> (i_value > 0) ? (1 / ceil(i_value)) : 0
>
> print i_value
> endin
>
> output
>
> SECTION 1:
> new alloc for instr 1:
> WARNING: Division by zero
> WARNING: Division by zero
> instr 1: i_value = 0.000
>
>
>
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
> https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
>
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |