[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] Rounding 'n' for do, Array.fill etc.?
- To: sc-dev <sc-dev@xxxxxxxxxxxxxxxx>
- Subject: [sc-dev] Rounding 'n' for do, Array.fill etc.?
- From: James Harkins <jamshark70@xxxxxxxxx>
- Date: Sun, 29 Dec 2013 19:03:43 +0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:date:message-id:subject:from:to:content-type; bh=aLr9oDf0J+aXYszitRWHKxKOqDLcr4cIGFyDL0Dxb3E=; b=p+OO3DiQH7h+DjPcu2XY0e55qA8G+dLRoCQMroGc/sSdFzaapJULI5fMAGXocwO9eL aSUshnOHg1YXHplcElUqh9Ln7jihtpzuiFnV8KBX1BW+ncosL6qb0XYvlYgcGTM7CcGQ A3aRJldMBSCqRGiuVjhmRydn4gwjAXDxR8AcmFaOF+O/2o6Z34eU9dlLfU8l5gZNsf48 zlW7tEIZZhryX4svnyoTjJENjMyIQdH/NlWEkcoOLqutwA1GC6VmHGedyiXBP7/hK+hP GxSrX+lK6YBXSbBvDfcHzwnJMUZyc7ENssG14942pLEwTsGNKjPhylVExZGQLPutjGP9 35iw==
- List-id: SuperCollider developers mailing list <sc-devel.create.ucsb.edu>
- Reply-to: sc-dev@xxxxxxxxxxxxxxxx
- Sender: owner-sc-dev@xxxxxxxxxxxxxxxx
Since when does Array.fill round the number of items to the nearest
integer (instead of truncating)?
Array.fill(1.6, { |i| i });
--> [ 0, 1 ]
Two elements? That seems incorrect to me.
For that matter, 'do':
1.4.do { |i| i.postln }; "" // prints 0
1.6.do { |i| i.postln }; "" // prints 0 and 1
Did I just never notice that this is what it's doing? Or has it really
always been that way?
I can't say I especially like this behavior. IMO, a number of
iterations is inherently an integer. If you give it a float, it should
be implicitly cast to integer, and that usually implies truncation of
the fractional part, not rounding. But, if it's always been like this
and people are relying on it, then I can live with writing the
explicit type-cast in my code.
hjh
_______________________________________________
sc-dev mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/