Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.misc > #5010

Re: The 8-Byte Two-Step

From Bob Eager <news0002@eager.cx>
Newsgroups comp.misc
Subject Re: The 8-Byte Two-Step
Date 2014-09-21 08:27 +0000
Message-ID <c87gfnFkjjcU1@mid.individual.net> (permalink)
References <01T8OImfoeUtayhTm1xJJ0vS@dont-email.me> <c86928Fkug2U4@mid.individual.net> <87ppeq2car.fsf@elektro.pacujo.net>

Show all headers | View raw


On Sun, 21 Sep 2014 00:48:44 +0300, Marko Rauhamaa wrote:

> Bob Eager <news0002@eager.cx>:
> 
>>>    (mqhp->mq_maxsz + MQ_ALIGNSIZE - 1) & ~(MQ_ALIGNSIZE - 1);
>>
>> Standard bit of code. I can't remember when I didn't know that one!
> 
> Yes, but I suppose the knowledge is fast eroding among coders. I can't
> remember having been taught it. I must have learned it from other
> people's assembly and C code.
> 
> Somehow that reminds me of an ancient trick I learned from some TI-56
> program. Here's a compact way to figure out how many days are between
> any (ISO 8601) dates:
> 
> ========================================================================
> #!/usr/bin/env python
> 
> import sys
> 
> def gregorian_day_count(isodate):
>     year, month, day = map(int, isodate.split('-'))
>     a, b = divmod(12 * year + month + 1185, 12)
>     return int(a * 365.2425) + int(30.573 * b + 0.706) + day
> 
> def main():
>     print gregorian_day_count(sys.argv[2]) -
>     gregorian_day_count(sys.argv[1])
> 
> if __name__ == '__main__':
>     main()
> ========================================================================
> 
> Usage:
> 
>     ./datediff.py 1960-02-03 2014-09-09
> 
> 
> Marko

Didn't know that one...thanks!



-- 
Using UNIX since v6 (1975)...

Use the BIG mirror service in the UK:
 http://www.mirrorservice.org

Back to comp.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

The 8-Byte Two-Step Rich <rich@example.invalid> - 2014-09-20 20:41 +0000
  Re: The 8-Byte Two-Step Bob Eager <news0002@eager.cx> - 2014-09-20 21:14 +0000
    Re: The 8-Byte Two-Step Marko Rauhamaa <marko@pacujo.net> - 2014-09-21 00:48 +0300
      Re: The 8-Byte Two-Step Bob Eager <news0002@eager.cx> - 2014-09-21 08:27 +0000
        Re: The 8-Byte Two-Step Marko Rauhamaa <marko@pacujo.net> - 2014-09-21 14:14 +0300
          Re: The 8-Byte Two-Step Marko Rauhamaa <marko@pacujo.net> - 2014-09-23 11:19 +0300
          Re: The 8-Byte Two-Step Christian Neukirchen <chneukirchen@gmail.com> - 2014-09-23 18:26 +0200
      Re: The 8-Byte Two-Step mm0fmf <none@mailinator.com> - 2014-09-21 20:45 +0100
  Re: The 8-Byte Two-Step Sylvia Else <sylvia@not.at.this.address> - 2014-09-21 13:42 +1000

csiph-web