Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: Split range 0 to M into N non-overlapping (roughly equal) ranges.

by BrowserUk (Patriarch)
on Mar 13, 2011 at 00:22 UTC ( [id://892881]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Split range 0 to M into N non-overlapping (roughly equal) ranges.
in thread Split range 0 to M into N non-overlapping (roughly equal) ranges.

Neat. I've written Bresenham routines several times in C and various assemblers, but I'd never encountered that variation.

The interesting thing is that once you whittle away the details irrelevant to my problem, you end up with the realisation that this is exactly what both javafan and mr_mischief came up with.

The significant thing in both implementations is that they defer the inting when calculating the step value, retaining it as a real, with the result that the residual get distributed evenly and automatically as they iterate the N partitions.

Simple once it is in front of you, but it was the trick I was missing.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^5: Split range 0 to M into N non-overlapping (roughly equal) ranges.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://892881]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-24 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found