home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snipps97.zip / METRIC.H < prev    next >
C/C++ Source or Header  |  1997-07-04  |  4KB  |  130 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*************************************************
  4. *
  5. *         ANSI C Metric Conversion Macros
  6. *              Mike Smith, Freeware
  7. *   6 Grenville Road, Plymouth, England, PL4 9PX
  8. *
  9. *             mike@msmith.demon.co.uk
  10. *
  11. *   Version: 1.03
  12. *   History: 5th of May, 1997
  13. *
  14. *   1.01 Taken out formulas and added values only Mon 17th April 1995
  15. *   1.02 Error corrections Sat 13th July 1996
  16. *   1.03 Added macros 5th of May, 1997
  17. *
  18. *=================================================
  19. *  While I have done my best to assure accuracy
  20. *     I can not confirm these are accurate.
  21. *
  22. *  This was done as part of a program which I
  23. *  did and I figured while I was at it I would
  24. *   do all of the conversions for the future.
  25. *     These tables are copied from a book.
  26. *
  27. * If you find any incorrect data or can add some
  28. *     more send them in, and the world can
  29. *            share these routines 
  30. *
  31. * If you would like a free update send me a disc
  32. *  and a stamp or request it via e-mail.
  33. *
  34. **************************************************/
  35.  
  36. #ifndef METRIC__H
  37. #define METRIC__H
  38.  
  39.  
  40. /******** Length Conversion Macros **********/
  41.  
  42. #define CM_TO_IN(x) (0.3937F * (x))
  43. #define IN_TO_CM(x) (2.54F * (x))
  44. #define IN_TO_M(x) (0.0254F * (x))
  45. #define IN_TO_MM(x) (25.4F * (x))
  46. #define KM_TO_MILE(x) (0.6214F * (x))
  47. #define M_TO_IN(x) (39.37F * (x))
  48. #define M_TO_YARD(x) (1.093611F * (x))
  49. #define MILE_TO_KM(x) (1.609F * (x))
  50. #define MM_TO_IN(x) (0.03937F * (x))
  51. #define YARD_TO_M(x) (0.9144F * (x))
  52. #define IN_TO_FT(x) ((x) / 12.0)
  53. #define IN_TO_YARD(x) ((x) / 36.0)
  54. #define IN_TO_MILE(x) ((x) / 63360.0)
  55. #define FT_TO_IN(x) (12.0 * (x))
  56. #define FT_TO_YARD(x) ((x) / 3.0)
  57. #define FT_TO_MILE(x) ((x) / 5280.0)
  58. #define MILE_TO_IN(x) (63360.0 * (x))
  59. #define MILE_TO_FT(x) (5280.0 * (x))
  60. #define MILE_TO_YARD(x) (1760.0 * (x))
  61.  
  62. /******* Weight Macros ************/
  63.  
  64. #define G_TO_OZ(x) (0.03527F * (x))
  65. #define KG_TO_LBS(x) (2.2046F * (x))
  66. #define LBS_TO_KG(x) (0.4545F * (x))
  67. #define LBS_TO_OZ(x) (16.0F * (x))
  68. #define OZ_TO_G(x) (28.3527F * (x))
  69. #define OZ_TO_LBS(x) ((x) / 16.0)
  70.  
  71. /******* Liquid Conversion Macros ********/
  72.  
  73. #define CL_TO_OZ(x) (0.338F * (x))
  74. #define ML_TO_OZ(x) (0.0338F * (x))
  75. #define OZ_TO_CL(x) (2.95857988F * (x))
  76. #define OZ_TO_ML(x) (29.5857F * (x))
  77.  
  78. /***********************************************
  79. *
  80. *      In case you are unaware there are:
  81. *           16 ounces in a US quart
  82. *           20 ounces in a UK quart
  83. *
  84. *  This, of course, makes gallons different
  85. *     too.  Supplied below are US to UK
  86. *           conversions as well.
  87. *
  88. ************************************************/
  89.  
  90. #define KL_TO_UKGAL(x) (211.344F * (x))
  91. #define KL_TO_USGAL(x) (264.18F * (x))
  92. #define L_TO_UKGAL(x) (0.2199F * (x))
  93. #define L_TO_UKQ(x) (0.945F * (x))
  94. #define L_TO_USGAL(x) (0.26455F * (x))
  95. #define L_TO_USQ(x) (1.0582F * (x))
  96. #define UKGAL_TO_KL(x) (0.0047316F * (x))
  97. #define UKGAL_TO_L(x) (4.546F * (x))
  98. #define UKGAL_TO_USGAL(x) (1.25F * (x))
  99. #define UKQ_TO_L(x) (1.0582F * (x))
  100. #define UKQ_TO_USQ(x) (1.25F * (x))
  101. #define USGAL_TO_KL(x) (0.003785F * (x))
  102. #define USGAL_TO_L(x) (3.78F * (x))
  103. #define USGAL_TO_UKGAL(x) (0.8F * (x))
  104. #define USQ_TO_L(x) (0.945F * (x))
  105. #define USQ_TO_UKQ(x) (0.8F * (x))
  106.  
  107. /**** Area Conversion Macros ****/
  108.  
  109. #define CM2_TO_IN2(x) (0.155F * (x))
  110. #define FT2_TO_M2(x) (0.0930F * (x))
  111. #define IN2_TO_CM2(x) (6.4516F * (x))
  112. #define IN2_TO_MM2(x) (645.161F * (x))
  113. #define KM2_TO_MILE2(x) (0.386F * (x))
  114. #define M2_TO_FT2(x) (10.75F * (x))
  115. #define MILE2_TO_KM2(x) (2.5906F * (x))
  116. #define MM2_TO_IN2(x) (0.00155F * (x))
  117.  
  118. /******** Volume Conversion Macros *********/
  119.  
  120. #define CM3_TO_IN3(x) (0.061F * (x))
  121. #define CM3_TO_IN3(x) (0.061F * (x))
  122. #define IN3_TO_CC(x) (16.3934F * (x))
  123. #define IN3_TO_CM3(x) (16.3934F * (x))
  124. #define KM3_TO_MILE3(x) (0.25F * (x))
  125. #define M3_TO_YARD3(x) (1.308F * (x))
  126. #define MILE3_TO_KM3(x) (4.0F * (x))
  127. #define YARD3_TO_M3(x) (0.764526F * (x))
  128.  
  129. #endif   /* METRIC__H */
  130.