[Csnd] Rounding and modulo operator

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] Rounding and modulo operator

gsenna
Hi,

I've noticed a thing with the % operator. I'm on 6.09.1.

print 9.999  % 10  ; this equals 9.999.
print 9.9999 % 10  ; this equals 10!

My math is not great, but is "m mod n" ever supposed to return n?

Cheers.

Csound mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Rounding and modulo operator

Steven Yi
Hi Guillermo,

I think that Csound's print opcode is rounding numbers, so the value
is correct but what you see in the print out is not what is expected.
The C code has:

      csound->MessageS(csound, CSOUNDMSG_ORCH,
                       "  %s = %5.3f", *txtp++, **valp++);

steven

On Tue, Oct 10, 2017 at 2:09 PM, Guillermo Senna <[hidden email]> wrote:

> Hi,
>
> I've noticed a thing with the % operator. I'm on 6.09.1.
>
> print 9.999  % 10  ; this equals 9.999.
> print 9.9999 % 10  ; this equals 10!
>
> My math is not great, but is "m mod n" ever supposed to return n?
>
> Cheers.
>
> Csound mailing list
> [hidden email]
> 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Rounding and modulo operator

gsenna
Oh, right! It's easy to fix what I'm doing then. Thanks, Steven.


On 10/10/17 15:22, Steven Yi wrote:

> Hi Guillermo,
>
> I think that Csound's print opcode is rounding numbers, so the value
> is correct but what you see in the print out is not what is expected.
> The C code has:
>
>       csound->MessageS(csound, CSOUNDMSG_ORCH,
>                        "  %s = %5.3f", *txtp++, **valp++);
>
> steven
>
> On Tue, Oct 10, 2017 at 2:09 PM, Guillermo Senna <[hidden email]> wrote:
>> Hi,
>>
>> I've noticed a thing with the % operator. I'm on 6.09.1.
>>
>> print 9.999  % 10  ; this equals 9.999.
>> print 9.9999 % 10  ; this equals 10!
>>
>> My math is not great, but is "m mod n" ever supposed to return n?
>>
>> Cheers.
>>
>> Csound mailing list
>> [hidden email]
>> 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
> [hidden email]
> 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
[hidden email]
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