hypot_basic.phpt 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. --TEST--
  2. Test hypot() - basic function test hypot()
  3. --INI--
  4. precision=14
  5. --FILE--
  6. <?php
  7. /* Prototype : float hypot ( float $x , float $y )
  8. * Description: Calculate the length of the hypotenuse of a right-angle triangle.
  9. * Source code: ext/standard/math.c
  10. */
  11. echo "*** Testing hypot() : basic functionality ***\n";
  12. $valuesy = array(23,
  13. -23,
  14. 2.345e1,
  15. -2.345e1,
  16. 0x17,
  17. 027,
  18. "23",
  19. "23.45",
  20. "2.345e1",
  21. "23abc",
  22. null,
  23. true,
  24. false);
  25. $valuesx = array(33,
  26. -33,
  27. 3.345e1,
  28. -3.345e1,
  29. 0x27,
  30. 037,
  31. "33",
  32. "43.45",
  33. "1.345e1",
  34. "33abc",
  35. null,
  36. true,
  37. false);
  38. for ($i = 0; $i < count($valuesy); $i++) {
  39. for ($j = 0; $j < count($valuesx); $j++) {
  40. echo "\nY:$valuesy[$i] X:$valuesx[$j] ";
  41. $res = hypot($valuesy[$i], $valuesx[$j]);
  42. var_dump($res);
  43. }
  44. }
  45. ?>
  46. ===Done===
  47. --EXPECTF--
  48. *** Testing hypot() : basic functionality ***
  49. Y:23 X:33 float(40.224370722238)
  50. Y:23 X:-33 float(40.224370722238)
  51. Y:23 X:33.45 float(40.594365372549)
  52. Y:23 X:-33.45 float(40.594365372549)
  53. Y:23 X:39 float(45.276925690687)
  54. Y:23 X:31 float(38.600518131238)
  55. Y:23 X:33 float(40.224370722238)
  56. Y:23 X:43.45 float(49.162002603637)
  57. Y:23 X:1.345e1 float(26.643995571235)
  58. Y:23 X:33abc
  59. Notice: A non well formed numeric value encountered in %s on line %d
  60. float(40.224370722238)
  61. Y:23 X: float(23)
  62. Y:23 X:1 float(23.021728866443)
  63. Y:23 X: float(23)
  64. Y:-23 X:33 float(40.224370722238)
  65. Y:-23 X:-33 float(40.224370722238)
  66. Y:-23 X:33.45 float(40.594365372549)
  67. Y:-23 X:-33.45 float(40.594365372549)
  68. Y:-23 X:39 float(45.276925690687)
  69. Y:-23 X:31 float(38.600518131238)
  70. Y:-23 X:33 float(40.224370722238)
  71. Y:-23 X:43.45 float(49.162002603637)
  72. Y:-23 X:1.345e1 float(26.643995571235)
  73. Y:-23 X:33abc
  74. Notice: A non well formed numeric value encountered in %s on line %d
  75. float(40.224370722238)
  76. Y:-23 X: float(23)
  77. Y:-23 X:1 float(23.021728866443)
  78. Y:-23 X: float(23)
  79. Y:23.45 X:33 float(40.483360779461)
  80. Y:23.45 X:-33 float(40.483360779461)
  81. Y:23.45 X:33.45 float(40.851009779441)
  82. Y:23.45 X:-33.45 float(40.851009779441)
  83. Y:23.45 X:39 float(45.507169764774)
  84. Y:23.45 X:31 float(38.870329301409)
  85. Y:23.45 X:33 float(40.483360779461)
  86. Y:23.45 X:43.45 float(49.374132903779)
  87. Y:23.45 X:1.345e1 float(27.033405260899)
  88. Y:23.45 X:33abc
  89. Notice: A non well formed numeric value encountered in %s on line %d
  90. float(40.483360779461)
  91. Y:23.45 X: float(23.45)
  92. Y:23.45 X:1 float(23.471312276905)
  93. Y:23.45 X: float(23.45)
  94. Y:-23.45 X:33 float(40.483360779461)
  95. Y:-23.45 X:-33 float(40.483360779461)
  96. Y:-23.45 X:33.45 float(40.851009779441)
  97. Y:-23.45 X:-33.45 float(40.851009779441)
  98. Y:-23.45 X:39 float(45.507169764774)
  99. Y:-23.45 X:31 float(38.870329301409)
  100. Y:-23.45 X:33 float(40.483360779461)
  101. Y:-23.45 X:43.45 float(49.374132903779)
  102. Y:-23.45 X:1.345e1 float(27.033405260899)
  103. Y:-23.45 X:33abc
  104. Notice: A non well formed numeric value encountered in %s on line %d
  105. float(40.483360779461)
  106. Y:-23.45 X: float(23.45)
  107. Y:-23.45 X:1 float(23.471312276905)
  108. Y:-23.45 X: float(23.45)
  109. Y:23 X:33 float(40.224370722238)
  110. Y:23 X:-33 float(40.224370722238)
  111. Y:23 X:33.45 float(40.594365372549)
  112. Y:23 X:-33.45 float(40.594365372549)
  113. Y:23 X:39 float(45.276925690687)
  114. Y:23 X:31 float(38.600518131238)
  115. Y:23 X:33 float(40.224370722238)
  116. Y:23 X:43.45 float(49.162002603637)
  117. Y:23 X:1.345e1 float(26.643995571235)
  118. Y:23 X:33abc
  119. Notice: A non well formed numeric value encountered in %s on line %d
  120. float(40.224370722238)
  121. Y:23 X: float(23)
  122. Y:23 X:1 float(23.021728866443)
  123. Y:23 X: float(23)
  124. Y:23 X:33 float(40.224370722238)
  125. Y:23 X:-33 float(40.224370722238)
  126. Y:23 X:33.45 float(40.594365372549)
  127. Y:23 X:-33.45 float(40.594365372549)
  128. Y:23 X:39 float(45.276925690687)
  129. Y:23 X:31 float(38.600518131238)
  130. Y:23 X:33 float(40.224370722238)
  131. Y:23 X:43.45 float(49.162002603637)
  132. Y:23 X:1.345e1 float(26.643995571235)
  133. Y:23 X:33abc
  134. Notice: A non well formed numeric value encountered in %s on line %d
  135. float(40.224370722238)
  136. Y:23 X: float(23)
  137. Y:23 X:1 float(23.021728866443)
  138. Y:23 X: float(23)
  139. Y:23 X:33 float(40.224370722238)
  140. Y:23 X:-33 float(40.224370722238)
  141. Y:23 X:33.45 float(40.594365372549)
  142. Y:23 X:-33.45 float(40.594365372549)
  143. Y:23 X:39 float(45.276925690687)
  144. Y:23 X:31 float(38.600518131238)
  145. Y:23 X:33 float(40.224370722238)
  146. Y:23 X:43.45 float(49.162002603637)
  147. Y:23 X:1.345e1 float(26.643995571235)
  148. Y:23 X:33abc
  149. Notice: A non well formed numeric value encountered in %s on line %d
  150. float(40.224370722238)
  151. Y:23 X: float(23)
  152. Y:23 X:1 float(23.021728866443)
  153. Y:23 X: float(23)
  154. Y:23.45 X:33 float(40.483360779461)
  155. Y:23.45 X:-33 float(40.483360779461)
  156. Y:23.45 X:33.45 float(40.851009779441)
  157. Y:23.45 X:-33.45 float(40.851009779441)
  158. Y:23.45 X:39 float(45.507169764774)
  159. Y:23.45 X:31 float(38.870329301409)
  160. Y:23.45 X:33 float(40.483360779461)
  161. Y:23.45 X:43.45 float(49.374132903779)
  162. Y:23.45 X:1.345e1 float(27.033405260899)
  163. Y:23.45 X:33abc
  164. Notice: A non well formed numeric value encountered in %s on line %d
  165. float(40.483360779461)
  166. Y:23.45 X: float(23.45)
  167. Y:23.45 X:1 float(23.471312276905)
  168. Y:23.45 X: float(23.45)
  169. Y:2.345e1 X:33 float(40.483360779461)
  170. Y:2.345e1 X:-33 float(40.483360779461)
  171. Y:2.345e1 X:33.45 float(40.851009779441)
  172. Y:2.345e1 X:-33.45 float(40.851009779441)
  173. Y:2.345e1 X:39 float(45.507169764774)
  174. Y:2.345e1 X:31 float(38.870329301409)
  175. Y:2.345e1 X:33 float(40.483360779461)
  176. Y:2.345e1 X:43.45 float(49.374132903779)
  177. Y:2.345e1 X:1.345e1 float(27.033405260899)
  178. Y:2.345e1 X:33abc
  179. Notice: A non well formed numeric value encountered in %s on line %d
  180. float(40.483360779461)
  181. Y:2.345e1 X: float(23.45)
  182. Y:2.345e1 X:1 float(23.471312276905)
  183. Y:2.345e1 X: float(23.45)
  184. Y:23abc X:33
  185. Notice: A non well formed numeric value encountered in %s on line %d
  186. float(40.224370722238)
  187. Y:23abc X:-33
  188. Notice: A non well formed numeric value encountered in %s on line %d
  189. float(40.224370722238)
  190. Y:23abc X:33.45
  191. Notice: A non well formed numeric value encountered in %s on line %d
  192. float(40.594365372549)
  193. Y:23abc X:-33.45
  194. Notice: A non well formed numeric value encountered in %s on line %d
  195. float(40.594365372549)
  196. Y:23abc X:39
  197. Notice: A non well formed numeric value encountered in %s on line %d
  198. float(45.276925690687)
  199. Y:23abc X:31
  200. Notice: A non well formed numeric value encountered in %s on line %d
  201. float(38.600518131238)
  202. Y:23abc X:33
  203. Notice: A non well formed numeric value encountered in %s on line %d
  204. float(40.224370722238)
  205. Y:23abc X:43.45
  206. Notice: A non well formed numeric value encountered in %s on line %d
  207. float(49.162002603637)
  208. Y:23abc X:1.345e1
  209. Notice: A non well formed numeric value encountered in %s on line %d
  210. float(26.643995571235)
  211. Y:23abc X:33abc
  212. Notice: A non well formed numeric value encountered in %s on line %d
  213. Notice: A non well formed numeric value encountered in %s on line %d
  214. float(40.224370722238)
  215. Y:23abc X:
  216. Notice: A non well formed numeric value encountered in %s on line %d
  217. float(23)
  218. Y:23abc X:1
  219. Notice: A non well formed numeric value encountered in %s on line %d
  220. float(23.021728866443)
  221. Y:23abc X:
  222. Notice: A non well formed numeric value encountered in %s on line %d
  223. float(23)
  224. Y: X:33 float(33)
  225. Y: X:-33 float(33)
  226. Y: X:33.45 float(33.45)
  227. Y: X:-33.45 float(33.45)
  228. Y: X:39 float(39)
  229. Y: X:31 float(31)
  230. Y: X:33 float(33)
  231. Y: X:43.45 float(43.45)
  232. Y: X:1.345e1 float(13.45)
  233. Y: X:33abc
  234. Notice: A non well formed numeric value encountered in %s on line %d
  235. float(33)
  236. Y: X: float(0)
  237. Y: X:1 float(1)
  238. Y: X: float(0)
  239. Y:1 X:33 float(33.015148038438)
  240. Y:1 X:-33 float(33.015148038438)
  241. Y:1 X:33.45 float(33.464944344792)
  242. Y:1 X:-33.45 float(33.464944344792)
  243. Y:1 X:39 float(39.012818406262)
  244. Y:1 X:31 float(31.016124838542)
  245. Y:1 X:33 float(33.015148038438)
  246. Y:1 X:43.45 float(43.461505956421)
  247. Y:1 X:1.345e1 float(13.487123488721)
  248. Y:1 X:33abc
  249. Notice: A non well formed numeric value encountered in %s on line %d
  250. float(33.015148038438)
  251. Y:1 X: float(1)
  252. Y:1 X:1 float(1.4142135623731)
  253. Y:1 X: float(1)
  254. Y: X:33 float(33)
  255. Y: X:-33 float(33)
  256. Y: X:33.45 float(33.45)
  257. Y: X:-33.45 float(33.45)
  258. Y: X:39 float(39)
  259. Y: X:31 float(31)
  260. Y: X:33 float(33)
  261. Y: X:43.45 float(43.45)
  262. Y: X:1.345e1 float(13.45)
  263. Y: X:33abc
  264. Notice: A non well formed numeric value encountered in %s on line %d
  265. float(33)
  266. Y: X: float(0)
  267. Y: X:1 float(1)
  268. Y: X: float(0)
  269. ===Done===