home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / bsd / 11083 < prev    next >
Encoding:
Internet Message Format  |  1993-01-09  |  6.5 KB

  1. Xref: sparky comp.unix.bsd:11083 fj.os.386bsd:247
  2. Path: sparky!uunet!ccut!news.u-tokyo.ac.jp!yayoi!tansei1!mhiroshi
  3. From: mhiroshi@tansei.cc.u-tokyo.ac.jp (H. Murakami)
  4. Newsgroups: comp.unix.bsd,fj.os.386bsd
  5. Subject: [386bsd] A cheap Japanese fix of vfprintf.c
  6. Message-ID: <3861@tansei1.tansei.cc.u-tokyo.ac.jp>
  7. Date: 10 Jan 93 01:29:16 GMT
  8. Sender: news@tansei.cc.u-tokyo.ac.jp
  9. Followup-To: comp.unix.bsd
  10. Organization: Hokkaido Univ. However I am subject to tansei for JUNET.
  11. Lines: 193
  12.  
  13. To: comp.unix.bsd,fj.os.386bsd
  14. Subject: [386bsd] A cheap Japanese fix of vfprintf.
  15.  
  16. If this patch if applied to the file /usr/src/lib/libc/stdio/vfprintf.c,
  17. the value out of range trouble detected by the enquire will go away.
  18.  
  19. The value 0.01 is good for the values of not huge,
  20. however, for the values of very large, 0.01 is to be changed
  21. something 0.005 or 0.001 to pass the enquire test is detected.
  22.  
  23. ======  The following is the output from enquire after this fix is applied.
  24. ======  It is a pity thing that there still remains two warnings.
  25.  
  26. Script started on Sun Jan 10 10:08:25 1993
  27. % a.out
  28. Produced by enquire version 4.3, CWI, Amsterdam
  29. Compiler claims to be ANSI C level 1
  30.  
  31. SIZES
  32. char = 8 bits, signed
  33. short=16 int=32 long=32 float=32 double=64 bits 
  34. long double=64 bits
  35. char*=32 bits
  36. int* =32 bits
  37. func*=32 bits
  38. Type size_t is unsigned int/long
  39. Type size_t is unsigned int/long
  40.  
  41. ALIGNMENTS
  42. char=1 short=2 int=4 long=4
  43. float=4 double=4
  44. long double=4
  45. char*=4 int*=4 func*=4
  46.  
  47. CHARACTER ORDER
  48. short: BA
  49. int:   DCBA
  50. long:  DCBA
  51.  
  52. PROPERTIES OF POINTERS
  53. Char and int pointer formats seem identical
  54. Char and function pointer formats seem identical
  55. Strings are shared
  56. Type ptrdiff_t is signed int/long
  57.  
  58. PROPERTIES OF INTEGRAL TYPES
  59. Overflow of a short does not generate a trap
  60. Maximum short = 32767 (= 2**15-1)
  61. Minimum short = -32768
  62. Overflow of an int does not generate a trap
  63. Maximum int = 2147483647 (= 2**31-1)
  64. Minimum int = -2147483648
  65. Overflow of a long does not generate a trap
  66. Maximum long = 2147483647 (= 2**31-1)
  67. Minimum long = -2147483648
  68. Maximum unsigned short = 65535
  69. Maximum unsigned int = 4294967295
  70. Maximum unsigned long = 4294967295
  71.  
  72. PROMOTIONS
  73. unsigned short promotes to signed int/long
  74. long+unsigned gives unsigned int/long
  75.  
  76. PROPERTIES OF FLOAT
  77. Base = 2
  78. Significant base digits = 24 (= at least 6 decimal digits)
  79. Arithmetic rounds towards nearest
  80.    Tie breaking rounds to even
  81. Smallest x such that 1.0-base**x != 1.0 = -24
  82. Smallest x such that 1.0-x != 1.0 = 2.98023259e-08
  83. Smallest x such that 1.0+base**x != 1.0 = -23
  84. Smallest x such that 1.0+x != 1.0 = 5.96046519e-08
  85. (Above number + 1.0) - 1.0 = 1.19209290e-07
  86. Number of bits used for exponent = 8
  87. Minimum normalised exponent = -126
  88. Minimum normalised positive number = 1.17549435e-38
  89. The smallest numbers are not kept normalised
  90. Smallest unnormalised positive number = 1.40129846e-45
  91. Float overflow generates a trap
  92. Maximum exponent = 128
  93. Maximum number = 3.40282347e+38
  94. Arithmetic uses a hidden bit
  95. It looks like single length IEEE format
  96.  
  97. PROPERTIES OF DOUBLE
  98. Base = 2
  99. Significant base digits = 53 (= at least 15 decimal digits)
  100. Arithmetic rounds towards nearest
  101.    Tie breaking rounds to even
  102. Smallest x such that 1.0-base**x != 1.0 = -53
  103. Smallest x such that 1.0-x != 1.0 = 5.5538256285569974e-17
  104. Smallest x such that 1.0+base**x != 1.0 = -52
  105. Smallest x such that 1.0+x != 1.0 = 1.1107651257113995e-16
  106. (Above number + 1.0) - 1.0 = 2.2204460492503131e-16
  107. Number of bits used for exponent = 11
  108. Minimum normalised exponent = -1022
  109. Minimum normalised positive number = 2.2250738585072010e-308
  110.  
  111. *** WARNING: Possibly bad output from printf above
  112.     expected value around 2.2250738585072010e-308, bit pattern:
  113.     00000000 00000000 00000000 00000000 00000000 00000000 00010000 00000000
  114.     sscanf gave           2.2250738585072010e-308, bit pattern:
  115.     11111111 11111111 11111111 11111111 11111111 11111111 00001111 00000000
  116.     difference= 4.9406564584124659e-324
  117.  
  118. The smallest numbers are not kept normalised
  119. Smallest unnormalised positive number = 4.9406564584124659e-324
  120. There is an 'infinite' value
  121. Maximum exponent = 1024
  122. Maximum number = 1.7976931348623157e+308
  123. Arithmetic uses a hidden bit
  124. It looks like double length IEEE format
  125.  
  126. PROPERTIES OF LONG DOUBLE
  127. Base = 2
  128. Significant base digits = 53 (= at least 15 decimal digits)
  129. Arithmetic rounds towards nearest
  130.    Tie breaking rounds to even
  131. Smallest x such that 1.0-base**x != 1.0 = -53
  132. Smallest x such that 1.0-x != 1.0 = 5.5538256285569974e-17
  133. Smallest x such that 1.0+base**x != 1.0 = -52
  134. Smallest x such that 1.0+x != 1.0 = 1.1107651257113995e-16
  135. (Above number + 1.0) - 1.0 = 2.2204460492503131e-16
  136. Number of bits used for exponent = 11
  137. Minimum normalised exponent = -1022
  138. Minimum normalised positive number = 2.2250738585072010e-308
  139.  
  140. *** WARNING: Possibly bad output from printf above
  141.     expected value around 2.2250738585072010e-308, bit pattern:
  142.     00000000 00000000 00000000 00000000 00000000 00000000 00010000 00000000
  143.     sscanf gave           2.2250738585072010e-308, bit pattern:
  144.     11111111 11111111 11111111 11111111 11111111 11111111 00001111 00000000
  145.     difference= 4.9406564584124659e-324
  146.  
  147. The smallest numbers are not kept normalised
  148. Smallest unnormalised positive number = 4.9406564584124659e-324
  149. There is an 'infinite' value
  150. Maximum exponent = 1024
  151. Maximum number = 1.7976931348623157e+308
  152. Arithmetic uses a hidden bit
  153. It looks like double length IEEE format
  154.  
  155. Float expressions are evaluated in a higher precision than double,
  156.    using 64 base digits
  157. Double expressions are evaluated in a higher precision than double,
  158.    using 64 base digits
  159. Long double expressions are evaluated in a higher precision than double,
  160.    using 64 base digits
  161. Memory mallocatable ~= 131008 Kbytes
  162.  
  163. For hints on dealing with the 2 problems above
  164.    see the section 'TROUBLESHOOTING' in the file enquire.c
  165. % exit
  166. Script done on Sun Jan 10 10:08:30 1993
  167.  
  168.  
  169.     Hiroshi Murakami
  170.  
  171. The patch follows.
  172.  
  173. *** vfprintf.c.org Sun Jan 10 10:01:50 1993
  174. --- vfprintf.c    Sun Jan 10 09:40:04 1993
  175. ***************
  176. *** 239,245 ****
  177. --- 239,249 ----
  178.   #if tahoe
  179.    register /* technically illegal, since we do not know what type va_list is */
  180.   #endif
  181. + #ifndef ORIGINAL
  182. +     _VA_LIST_ ap;
  183. + #else
  184.       va_list ap;
  185. + #endif
  186.   {
  187.       register char *fmt;    /* format string */
  188.       register int ch;    /* character from fmt */
  189. ***************
  190. *** 748,754 ****
  191. --- 752,762 ----
  192.        */
  193.       for (p = endp - 1; integer; ++expcnt) {
  194.           tmp = modf(integer / 10, &integer);
  195. + #ifndef ORIGINAL /* HIROSHI MURAKAMI */
  196. +         *p-- = to_char((int)((tmp + .001) * 10));
  197. + #else
  198.           *p-- = to_char((int)((tmp + .01) * 10));
  199. + #endif
  200.       }
  201.       switch (fmtch) {
  202.       case 'f':
  203.  
  204.  
  205. END OF THIS MESSAGE.
  206.