number.h.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. number.h
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='node.h.html' title=' node.h '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='nvm.h.html' title=' nvm.h '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * number.h - numeric conversion definitions and declarations;
  24. *
  25. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  26. * Copyright 2001-2006 by Charles Maier Associates;
  27. * Licensed under the Internet Software Consortium License;
  28. *
  29. *--------------------------------------------------------------------*/
  30. #ifndef NUMBER_HEADER
  31. #define NUMBER_HEADER
  32. /*====================================================================*
  33. * system header files;
  34. *--------------------------------------------------------------------*/
  35. #include &lt;stdio.h&gt;
  36. #include &lt;stdint.h&gt;
  37. #include &lt;stddef.h&gt;
  38. /*====================================================================*
  39. * numeric converson sizes and limits;
  40. *--------------------------------------------------------------------*/
  41. #define RADIX_BIN 2
  42. #define RADIX_OCT 8
  43. #define RADIX_DEC 10
  44. #define RADIX_HEX 16
  45. #define RADIX_MIN 2
  46. #define RADIX_MAX 36
  47. #define BIN_DIGITS 8
  48. #define DEC_DIGITS 3
  49. #define OCT_DIGITS 3
  50. #define HEX_DIGITS 2
  51. #define IPv4_SIZE 4
  52. #define IPv6_SIZE 16
  53. /*====================================================================*
  54. * numeric conversion strings;
  55. *--------------------------------------------------------------------*/
  56. #define DIGITS_BIN &quot;01&quot;
  57. #define DIGITS_OCT &quot;01234567&quot;
  58. #define DIGITS_DEC &quot;0123456789&quot;
  59. #define DIGITS_HEX &quot;0123456789ABCDEF&quot;
  60. #define DIGITS_ALL &quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;
  61. /*====================================================================*
  62. * numeric string extenders;
  63. *--------------------------------------------------------------------*/
  64. #define BIN_EXTENDER '-'
  65. #define DEC_EXTENDER '.'
  66. #define HEX_EXTENDER ':'
  67. /*====================================================================*
  68. *
  69. *--------------------------------------------------------------------*/
  70. #define isodd(n) (((n)&amp;(1)) != 0)
  71. #define iseven(n) (((n)&amp;(1)) == 0)
  72. /*====================================================================*
  73. *
  74. *--------------------------------------------------------------------*/
  75. uint64_t QCASRand (uint32_t seed);
  76. uint32_t QCARand ();
  77. /*====================================================================*
  78. *
  79. *--------------------------------------------------------------------*/
  80. uint64_t basespec (char const * string, unsigned base, unsigned size);
  81. uint64_t uintspec (char const * string, uint64_t minimum, uint64_t maximum);
  82. uint64_t tonumber (char const * string, uint64_t minimum, uint64_t maximum, uint64_t nominal);
  83. signed sintspec (char const *string, signed number);
  84. unsigned totruth (char const *string, signed fail);
  85. unsigned todigit (unsigned c);
  86. /*====================================================================*
  87. * end definitions;
  88. *--------------------------------------------------------------------*/
  89. #endif
  90. </pre>
  91. <div class='footerlink'>
  92. [<a href='node.h.html' title=' node.h '>PREV</a>]
  93. [<a href='toolkit.html' title=' Index '>HOME</a>]
  94. [<a href='nvm.h.html' title=' nvm.h '>NEXT</a>]
  95. </div>
  96. </body>
  97. </html>