rtlp.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*++
  2. Copyright (c) 2013 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. rtlp.h
  5. Abstract:
  6. This header contains internal definitions for the Runtime Library.
  7. Author:
  8. Evan Green 19-Feb-2013
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. #ifndef RTL_API
  14. #define RTL_API __DLLPROTECTED
  15. #endif
  16. //
  17. // Define away the kernel API decorator since Rtl is always linked statically
  18. // with the kernel.
  19. //
  20. #define KERNEL_API
  21. #include <minoca/lib/types.h>
  22. #include <minoca/lib/status.h>
  23. #include <minoca/lib/rtl.h>
  24. //
  25. // ---------------------------------------------------------------- Definitions
  26. //
  27. //
  28. // Define common print format values.
  29. //
  30. #define DEFAULT_FLOAT_PRECISION 6
  31. #define MAX_DOUBLE_DIGITS_SIZE 15
  32. #define MAX_DOUBLE_EXPONENT_SIZE 7
  33. #define SCIENTIFIC_NOTATION_AUTO_LOWER_LIMIT -4
  34. #define LOG2 0.30102999566398119521
  35. //
  36. // Define the string size of the longest possible integer,
  37. // 01000000000000000000000 (octal).
  38. //
  39. #define MAX_INTEGER_STRING_SIZE 24
  40. //
  41. // ------------------------------------------------------ Data Type Definitions
  42. //
  43. //
  44. // Define some types the C library expects but that aren't necessarily defined
  45. // in the kernel.
  46. //
  47. typedef long long intmax_t;
  48. typedef __PTRDIFF_TYPE__ ptrdiff_t;
  49. typedef __SIZE_TYPE__ size_t;
  50. /*++
  51. Structure Description:
  52. This structure defines the properties associated with printing a format
  53. specifier.
  54. Members:
  55. Radix - Stores the base to print the number in.
  56. FieldWidth - Stores the width of the field to print.
  57. IntegerSize - Stores the size of the integer being printed, in bytes.
  58. Precision - Stores the desired precision, in digits.
  59. AlwaysPrintSign - Stores a boolean indicating whether or not to always
  60. print a sign (normally positive values have their signs omitted).
  61. LeftJustified - Stores a boolean indicating if the value is left justified
  62. to its field (normally it's right justified).
  63. PrintUpperCase - Stores a boolean indicating whether letters used in
  64. numbers (like hex or the exponent letter) should be printed in upper
  65. case.
  66. PrintLeadingZeroes - Stores a boolean indicating if leading zeros should be
  67. printed to fill the field width.
  68. PrintRadix - Stores a boolean indicating if a radix (0x) should be printed.
  69. SpaceForPlus - Stores a boolean indicating if a space should be left in
  70. lieu of the plus sign for positive values.
  71. ThousandsGrouping - Stores a boolean indicating if thousands should be
  72. grouped together.
  73. Unsigned - Stores a boolean indicating if the integer is unsigned.
  74. FloatFormat - Stores a boolean indicating whether to use the float format
  75. in which all significant digits are printed. If both this and the
  76. scientific format booleans are false, an automatic selection will be
  77. made.
  78. ScientificFormat - Stores a boolean indicating whether to use the
  79. scientific floating poing format in which an exponent is printed. If
  80. both this and the scientific format booleans are false, an automatic
  81. selection will be made.
  82. SignificantDigitPrecision - Stores a boolean indicating if the precision
  83. represents the number of digits after the decimal point (FALSE) or the
  84. number of significant digits (TRUE).
  85. --*/
  86. typedef struct _PRINT_FORMAT_PROPERTIES {
  87. ULONG Radix;
  88. LONG FieldWidth;
  89. LONG IntegerSize;
  90. LONG Precision;
  91. BOOL AlwaysPrintSign;
  92. BOOL LeftJustified;
  93. BOOL PrintUpperCase;
  94. BOOL PrintLeadingZeroes;
  95. BOOL PrintRadix;
  96. BOOL SpaceForPlus;
  97. BOOL ThousandsGrouping;
  98. BOOL Unsigned;
  99. BOOL FloatFormat;
  100. BOOL ScientificFormat;
  101. BOOL SignificantDigitPrecision;
  102. } PRINT_FORMAT_PROPERTIES, *PPRINT_FORMAT_PROPERTIES;
  103. //
  104. // -------------------------------------------------------------------- Globals
  105. //
  106. //
  107. // Store some numeric constants used for string scanning.
  108. //
  109. extern double RtlFirst16NegativePowersOf10[16];
  110. extern double RtlFirst16PowersOf10[16];
  111. extern double RtlPositivePowersOf2[5];
  112. extern double RtlNegativePowersOf2[5];
  113. //
  114. // -------------------------------------------------------- Function Prototypes
  115. //
  116. LONG
  117. RtlpGetDoubleBase10Exponent (
  118. double Value,
  119. double *InversePowerOfTen
  120. );
  121. /*++
  122. Routine Description:
  123. This routine gets the base 10 exponent of the given double.
  124. Arguments:
  125. Value - Supplies the value to get the base 10 exponent of.
  126. InversePowerOfTen - Supplies a pointer where the power of 10 correponding
  127. to the returned exponent will be returned.
  128. Return Value:
  129. Returns the base 10 exponent of the given value.
  130. --*/