todigit.c.html 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. todigit.c
  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='termlist.c.html' title=' termlist.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='ToneMaps1.c.html' title=' ToneMaps1.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * unsigned todigit (unsigned c);
  24. *
  25. * number.h
  26. *
  27. * return the unsigned integer equivalent of an ASCII digit or the
  28. * value UCHAR_MAX on error;
  29. *
  30. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  31. * Copyright (c) 2001-2006 by Charles Maier Associates;
  32. * Licensed under the Internet Software Consortium License;
  33. *
  34. *--------------------------------------------------------------------*/
  35. #ifndef TODIGIT_SOURCE
  36. #define TODIGIT_SOURCE
  37. #include &lt;limits.h&gt;
  38. #include &quot;../tools/number.h&quot;
  39. unsigned todigit (unsigned c)
  40. {
  41. if ((c &gt;= '0') &amp;&amp; (c &lt;= '9'))
  42. {
  43. return (c - '0');
  44. }
  45. if ((c &gt;= 'A') &amp;&amp; (c &lt;= 'Z'))
  46. {
  47. return (c - 'A' + 10);
  48. }
  49. if ((c &gt;= 'a') &amp;&amp; (c &lt;= 'z'))
  50. {
  51. return (c - 'a' + 10);
  52. }
  53. return (UCHAR_MAX);
  54. }
  55. #endif
  56. </pre>
  57. <div class='footerlink'>
  58. [<a href='termlist.c.html' title=' termlist.c '>PREV</a>]
  59. [<a href='toolkit.html' title=' Index '>HOME</a>]
  60. [<a href='ToneMaps1.c.html' title=' ToneMaps1.c '>NEXT</a>]
  61. </div>
  62. </body>
  63. </html>