Skip to content

Instantly share code, notes, and snippets.

@leddoo
Created March 31, 2024 11:12
Show Gist options
  • Save leddoo/d1ee9848852600c6fd7cdc0c89cc042b to your computer and use it in GitHub Desktop.
Save leddoo/d1ee9848852600c6fd7cdc0c89cc042b to your computer and use it in GitHub Desktop.

how long does it take until a 32/64 bit integer wraps when incrementing at a constant rate?

2^32:

 frequency | period | years | days    | hours     | minutes    | seconds      | milliseconds
-----------+--------+-------+---------+-----------+------------+--------------+-----------------
     1 Hz  |   1 s  | 136.1 | 49710.3 | 1193046.5 | 71582788.3 | 4294967296.0 | 4294967296000.0
    10 Hz  | 100 ms |  13.6 |  4971.0 |  119304.6 |  7158278.8 |  429496729.6 |  429496729600.0
   100 Hz  |  10 ms |   1.4 |   497.1 |   11930.5 |   715827.9 |   42949673.0 |   42949672960.0
     1 kHz |   1 ms |   0.1 |    49.7 |    1193.0 |    71582.8 |    4294967.3 |    4294967296.0
    10 kHz | 100 µs |   0.0 |     5.0 |     119.3 |     7158.3 |     429496.7 |     429496729.6
   100 kHz |  10 µs |   0.0 |     0.5 |      11.9 |      715.8 |      42949.7 |      42949673.0
     1 MHz |   1 µs |   0.0 |     0.0 |       1.2 |       71.6 |       4295.0 |       4294967.3
    10 MHz | 100 ns |   0.0 |     0.0 |       0.1 |        7.2 |        429.5 |        429496.7
   100 MHz |  10 ns |   0.0 |     0.0 |       0.0 |        0.7 |         42.9 |         42949.7
     1 GHz |   1 ns |   0.0 |     0.0 |       0.0 |        0.1 |          4.3 |          4295.0
    10 GHz | 100 ps |   0.0 |     0.0 |       0.0 |        0.0 |          0.4 |           429.5

2^64:

 frequency | period | years
-----------+--------+----------
     1 MHz |   1 µs | 584554.0
    10 MHz | 100 ns |  58455.4
   100 MHz |  10 ns |   5845.5
     1 GHz |   1 ns |    584.6
    10 GHz | 100 ps |     58.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment