Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.programming    |    Programming issues that transcend langua    |    57,431 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 56,701 of 57,431    |
|    Dmitry A. Kazakov to Richard Harnden    |
|    Re: A little puzzle.    |
|    29 Nov 22 16:13:07    |
   
   From: mailbox@dmitry-kazakov.de   
      
   On 2022-11-29 16:03, Richard Harnden wrote:   
      
   > Okay, so how about this ... ?   
   >   
   > int in_subrange(int_fast64_t range_min, int_fast64_t range_max,   
   > int_fast64_t start, int_fast64_t end, int_fast64_t check)   
   > {   
   > while ( check < range_min )   
   > check += range_max - range_min;   
      
   Ring modulo would be range_max - range_min + 1   
      
   > It's okay for check to have 'clocked', range_min, range_max, start and   
   > end have sensible values.   
      
   If the language supports modular and ranged types there is no need to   
   check/normalize arguments.   
      
   --   
   Regards,   
   Dmitry A. Kazakov   
   http://www.dmitry-kazakov.de   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca