Csound Csound-dev Csound-tekno Search About

Re: Floating point problems and sscanf

Date1998-04-08 00:04
Fromrasmus ekman
SubjectRe: Floating point problems and sscanf
Eli Brandt wrote:
> 
> Stephen Brandon - SysAdmin wrote:
> > sr = 22050.000000, kr = 1000.000000, ksmps = 22.049999
> 
> As you probably know, 22.05 can't be represented exactly.  I'm not
> certain what's going on in your code fragment 

Um, let it be known that ksmps must be integer, ok?
eg sr = 22050, kr = 294, ksmps = 75, etc.
(If you're poking around in the code, you'll find that 
ksmps is used as a loop counter: control variables are
updated at the lower k-rate (kr), then each instrument 
computes ksmps number of samples using these values.)

> (Might "ksmps = sr/kr" work better?  Dunno whether it's even legal.)

Should be, but as you say, unnecessary.

hth,

	re

Date1998-04-08 02:49
FromEli Brandt
SubjectRe: Floating point problems and sscanf
rasmus ekman wrote:
> Um, let it be known that ksmps must be integer, ok?

Oh, duh -- I got in "floating-point equality" mode and forgot what
ksmps _was_. :-)

-- 
     Eli Brandt  |  eli+@cs.cmu.edu  |  http://www.cs.cmu.edu/~eli/