Math.hx 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366
  1. package java.lang;
  2. /*
  3. * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
  4. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5. *
  6. * This code is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 only, as
  8. * published by the Free Software Foundation. Oracle designates this
  9. * particular file as subject to the "Classpath" exception as provided
  10. * by Oracle in the LICENSE file that accompanied this code.
  11. *
  12. * This code is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  15. * version 2 for more details (a copy is included in the LICENSE file that
  16. * accompanied this code).
  17. *
  18. * You should have received a copy of the GNU General Public License version
  19. * 2 along with this work; if not, write to the Free Software Foundation,
  20. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21. *
  22. * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  23. * or visit www.oracle.com if you need additional information or have any
  24. * questions.
  25. */
  26. /**
  27. * The class {@code Math} contains methods for performing basic
  28. * numeric operations such as the elementary exponential, logarithm,
  29. * square root, and trigonometric functions.
  30. *
  31. * <p>Unlike some of the numeric methods of class
  32. * {@code StrictMath}, all implementations of the equivalent
  33. * functions of class {@code Math} are not defined to return the
  34. * bit-for-bit same results. This relaxation permits
  35. * better-performing implementations where strict reproducibility is
  36. * not required.
  37. *
  38. * <p>By default many of the {@code Math} methods simply call
  39. * the equivalent method in {@code StrictMath} for their
  40. * implementation. Code generators are encouraged to use
  41. * platform-specific native libraries or microprocessor instructions,
  42. * where available, to provide higher-performance implementations of
  43. * {@code Math} methods. Such higher-performance
  44. * implementations still must conform to the specification for
  45. * {@code Math}.
  46. *
  47. * <p>The quality of implementation specifications concern two
  48. * properties, accuracy of the returned result and monotonicity of the
  49. * method. Accuracy of the floating-point {@code Math} methods
  50. * is measured in terms of <i>ulps</i>, units in the last place. For
  51. * a given floating-point format, an ulp of a specific real number
  52. * value is the distance between the two floating-point values
  53. * bracketing that numerical value. When discussing the accuracy of a
  54. * method as a whole rather than at a specific argument, the number of
  55. * ulps cited is for the worst-case error at any argument. If a
  56. * method always has an error less than 0.5 ulps, the method always
  57. * returns the floating-point number nearest the exact result; such a
  58. * method is <i>correctly rounded</i>. A correctly rounded method is
  59. * generally the best a floating-point approximation can be; however,
  60. * it is impractical for many floating-point methods to be correctly
  61. * rounded. Instead, for the {@code Math} class, a larger error
  62. * bound of 1 or 2 ulps is allowed for certain methods. Informally,
  63. * with a 1 ulp error bound, when the exact result is a representable
  64. * number, the exact result should be returned as the computed result;
  65. * otherwise, either of the two floating-point values which bracket
  66. * the exact result may be returned. For exact results large in
  67. * magnitude, one of the endpoints of the bracket may be infinite.
  68. * Besides accuracy at individual arguments, maintaining proper
  69. * relations between the method at different arguments is also
  70. * important. Therefore, most methods with more than 0.5 ulp errors
  71. * are required to be <i>semi-monotonic</i>: whenever the mathematical
  72. * function is non-decreasing, so is the floating-point approximation,
  73. * likewise, whenever the mathematical function is non-increasing, so
  74. * is the floating-point approximation. Not all approximations that
  75. * have 1 ulp accuracy will automatically meet the monotonicity
  76. * requirements.
  77. *
  78. * @author unascribed
  79. * @author Joseph D. Darcy
  80. * @since JDK1.0
  81. */
  82. @:require(java0) extern class Math
  83. {
  84. /**
  85. * The {@code double} value that is closer than any other to
  86. * <i>e</i>, the base of the natural logarithms.
  87. */
  88. public static var E(default, null) : Float;
  89. /**
  90. * The {@code double} value that is closer than any other to
  91. * <i>pi</i>, the ratio of the circumference of a circle to its
  92. * diameter.
  93. */
  94. public static var PI(default, null) : Float;
  95. /**
  96. * Returns the trigonometric sine of an angle. Special cases:
  97. * <ul><li>If the argument is NaN or an infinity, then the
  98. * result is NaN.
  99. * <li>If the argument is zero, then the result is a zero with the
  100. * same sign as the argument.</ul>
  101. *
  102. * <p>The computed result must be within 1 ulp of the exact result.
  103. * Results must be semi-monotonic.
  104. *
  105. * @param a an angle, in radians.
  106. * @return the sine of the argument.
  107. */
  108. @:overload public static function sin(a : Float) : Float;
  109. /**
  110. * Returns the trigonometric cosine of an angle. Special cases:
  111. * <ul><li>If the argument is NaN or an infinity, then the
  112. * result is NaN.</ul>
  113. *
  114. * <p>The computed result must be within 1 ulp of the exact result.
  115. * Results must be semi-monotonic.
  116. *
  117. * @param a an angle, in radians.
  118. * @return the cosine of the argument.
  119. */
  120. @:overload public static function cos(a : Float) : Float;
  121. /**
  122. * Returns the trigonometric tangent of an angle. Special cases:
  123. * <ul><li>If the argument is NaN or an infinity, then the result
  124. * is NaN.
  125. * <li>If the argument is zero, then the result is a zero with the
  126. * same sign as the argument.</ul>
  127. *
  128. * <p>The computed result must be within 1 ulp of the exact result.
  129. * Results must be semi-monotonic.
  130. *
  131. * @param a an angle, in radians.
  132. * @return the tangent of the argument.
  133. */
  134. @:overload public static function tan(a : Float) : Float;
  135. /**
  136. * Returns the arc sine of a value; the returned angle is in the
  137. * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
  138. * <ul><li>If the argument is NaN or its absolute value is greater
  139. * than 1, then the result is NaN.
  140. * <li>If the argument is zero, then the result is a zero with the
  141. * same sign as the argument.</ul>
  142. *
  143. * <p>The computed result must be within 1 ulp of the exact result.
  144. * Results must be semi-monotonic.
  145. *
  146. * @param a the value whose arc sine is to be returned.
  147. * @return the arc sine of the argument.
  148. */
  149. @:overload public static function asin(a : Float) : Float;
  150. /**
  151. * Returns the arc cosine of a value; the returned angle is in the
  152. * range 0.0 through <i>pi</i>. Special case:
  153. * <ul><li>If the argument is NaN or its absolute value is greater
  154. * than 1, then the result is NaN.</ul>
  155. *
  156. * <p>The computed result must be within 1 ulp of the exact result.
  157. * Results must be semi-monotonic.
  158. *
  159. * @param a the value whose arc cosine is to be returned.
  160. * @return the arc cosine of the argument.
  161. */
  162. @:overload public static function acos(a : Float) : Float;
  163. /**
  164. * Returns the arc tangent of a value; the returned angle is in the
  165. * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
  166. * <ul><li>If the argument is NaN, then the result is NaN.
  167. * <li>If the argument is zero, then the result is a zero with the
  168. * same sign as the argument.</ul>
  169. *
  170. * <p>The computed result must be within 1 ulp of the exact result.
  171. * Results must be semi-monotonic.
  172. *
  173. * @param a the value whose arc tangent is to be returned.
  174. * @return the arc tangent of the argument.
  175. */
  176. @:overload public static function atan(a : Float) : Float;
  177. /**
  178. * Converts an angle measured in degrees to an approximately
  179. * equivalent angle measured in radians. The conversion from
  180. * degrees to radians is generally inexact.
  181. *
  182. * @param angdeg an angle, in degrees
  183. * @return the measurement of the angle {@code angdeg}
  184. * in radians.
  185. * @since 1.2
  186. */
  187. @:require(java2) @:overload public static function toRadians(angdeg : Float) : Float;
  188. /**
  189. * Converts an angle measured in radians to an approximately
  190. * equivalent angle measured in degrees. The conversion from
  191. * radians to degrees is generally inexact; users should
  192. * <i>not</i> expect {@code cos(toRadians(90.0))} to exactly
  193. * equal {@code 0.0}.
  194. *
  195. * @param angrad an angle, in radians
  196. * @return the measurement of the angle {@code angrad}
  197. * in degrees.
  198. * @since 1.2
  199. */
  200. @:require(java2) @:overload public static function toDegrees(angrad : Float) : Float;
  201. /**
  202. * Returns Euler's number <i>e</i> raised to the power of a
  203. * {@code double} value. Special cases:
  204. * <ul><li>If the argument is NaN, the result is NaN.
  205. * <li>If the argument is positive infinity, then the result is
  206. * positive infinity.
  207. * <li>If the argument is negative infinity, then the result is
  208. * positive zero.</ul>
  209. *
  210. * <p>The computed result must be within 1 ulp of the exact result.
  211. * Results must be semi-monotonic.
  212. *
  213. * @param a the exponent to raise <i>e</i> to.
  214. * @return the value <i>e</i><sup>{@code a}</sup>,
  215. * where <i>e</i> is the base of the natural logarithms.
  216. */
  217. @:overload public static function exp(a : Float) : Float;
  218. /**
  219. * Returns the natural logarithm (base <i>e</i>) of a {@code double}
  220. * value. Special cases:
  221. * <ul><li>If the argument is NaN or less than zero, then the result
  222. * is NaN.
  223. * <li>If the argument is positive infinity, then the result is
  224. * positive infinity.
  225. * <li>If the argument is positive zero or negative zero, then the
  226. * result is negative infinity.</ul>
  227. *
  228. * <p>The computed result must be within 1 ulp of the exact result.
  229. * Results must be semi-monotonic.
  230. *
  231. * @param a a value
  232. * @return the value ln&nbsp;{@code a}, the natural logarithm of
  233. * {@code a}.
  234. */
  235. @:overload public static function log(a : Float) : Float;
  236. /**
  237. * Returns the base 10 logarithm of a {@code double} value.
  238. * Special cases:
  239. *
  240. * <ul><li>If the argument is NaN or less than zero, then the result
  241. * is NaN.
  242. * <li>If the argument is positive infinity, then the result is
  243. * positive infinity.
  244. * <li>If the argument is positive zero or negative zero, then the
  245. * result is negative infinity.
  246. * <li> If the argument is equal to 10<sup><i>n</i></sup> for
  247. * integer <i>n</i>, then the result is <i>n</i>.
  248. * </ul>
  249. *
  250. * <p>The computed result must be within 1 ulp of the exact result.
  251. * Results must be semi-monotonic.
  252. *
  253. * @param a a value
  254. * @return the base 10 logarithm of {@code a}.
  255. * @since 1.5
  256. */
  257. @:require(java5) @:overload public static function log10(a : Float) : Float;
  258. /**
  259. * Returns the correctly rounded positive square root of a
  260. * {@code double} value.
  261. * Special cases:
  262. * <ul><li>If the argument is NaN or less than zero, then the result
  263. * is NaN.
  264. * <li>If the argument is positive infinity, then the result is positive
  265. * infinity.
  266. * <li>If the argument is positive zero or negative zero, then the
  267. * result is the same as the argument.</ul>
  268. * Otherwise, the result is the {@code double} value closest to
  269. * the true mathematical square root of the argument value.
  270. *
  271. * @param a a value.
  272. * @return the positive square root of {@code a}.
  273. * If the argument is NaN or less than zero, the result is NaN.
  274. */
  275. @:overload public static function sqrt(a : Float) : Float;
  276. /**
  277. * Returns the cube root of a {@code double} value. For
  278. * positive finite {@code x}, {@code cbrt(-x) ==
  279. * -cbrt(x)}; that is, the cube root of a negative value is
  280. * the negative of the cube root of that value's magnitude.
  281. *
  282. * Special cases:
  283. *
  284. * <ul>
  285. *
  286. * <li>If the argument is NaN, then the result is NaN.
  287. *
  288. * <li>If the argument is infinite, then the result is an infinity
  289. * with the same sign as the argument.
  290. *
  291. * <li>If the argument is zero, then the result is a zero with the
  292. * same sign as the argument.
  293. *
  294. * </ul>
  295. *
  296. * <p>The computed result must be within 1 ulp of the exact result.
  297. *
  298. * @param a a value.
  299. * @return the cube root of {@code a}.
  300. * @since 1.5
  301. */
  302. @:require(java5) @:overload public static function cbrt(a : Float) : Float;
  303. /**
  304. * Computes the remainder operation on two arguments as prescribed
  305. * by the IEEE 754 standard.
  306. * The remainder value is mathematically equal to
  307. * <code>f1&nbsp;-&nbsp;f2</code>&nbsp;&times;&nbsp;<i>n</i>,
  308. * where <i>n</i> is the mathematical integer closest to the exact
  309. * mathematical value of the quotient {@code f1/f2}, and if two
  310. * mathematical integers are equally close to {@code f1/f2},
  311. * then <i>n</i> is the integer that is even. If the remainder is
  312. * zero, its sign is the same as the sign of the first argument.
  313. * Special cases:
  314. * <ul><li>If either argument is NaN, or the first argument is infinite,
  315. * or the second argument is positive zero or negative zero, then the
  316. * result is NaN.
  317. * <li>If the first argument is finite and the second argument is
  318. * infinite, then the result is the same as the first argument.</ul>
  319. *
  320. * @param f1 the dividend.
  321. * @param f2 the divisor.
  322. * @return the remainder when {@code f1} is divided by
  323. * {@code f2}.
  324. */
  325. @:overload public static function IEEEremainder(f1 : Float, f2 : Float) : Float;
  326. /**
  327. * Returns the smallest (closest to negative infinity)
  328. * {@code double} value that is greater than or equal to the
  329. * argument and is equal to a mathematical integer. Special cases:
  330. * <ul><li>If the argument value is already equal to a
  331. * mathematical integer, then the result is the same as the
  332. * argument. <li>If the argument is NaN or an infinity or
  333. * positive zero or negative zero, then the result is the same as
  334. * the argument. <li>If the argument value is less than zero but
  335. * greater than -1.0, then the result is negative zero.</ul> Note
  336. * that the value of {@code Math.ceil(x)} is exactly the
  337. * value of {@code -Math.floor(-x)}.
  338. *
  339. *
  340. * @param a a value.
  341. * @return the smallest (closest to negative infinity)
  342. * floating-point value that is greater than or equal to
  343. * the argument and is equal to a mathematical integer.
  344. */
  345. @:overload public static function ceil(a : Float) : Float;
  346. /**
  347. * Returns the largest (closest to positive infinity)
  348. * {@code double} value that is less than or equal to the
  349. * argument and is equal to a mathematical integer. Special cases:
  350. * <ul><li>If the argument value is already equal to a
  351. * mathematical integer, then the result is the same as the
  352. * argument. <li>If the argument is NaN or an infinity or
  353. * positive zero or negative zero, then the result is the same as
  354. * the argument.</ul>
  355. *
  356. * @param a a value.
  357. * @return the largest (closest to positive infinity)
  358. * floating-point value that less than or equal to the argument
  359. * and is equal to a mathematical integer.
  360. */
  361. @:overload public static function floor(a : Float) : Float;
  362. /**
  363. * Returns the {@code double} value that is closest in value
  364. * to the argument and is equal to a mathematical integer. If two
  365. * {@code double} values that are mathematical integers are
  366. * equally close, the result is the integer value that is
  367. * even. Special cases:
  368. * <ul><li>If the argument value is already equal to a mathematical
  369. * integer, then the result is the same as the argument.
  370. * <li>If the argument is NaN or an infinity or positive zero or negative
  371. * zero, then the result is the same as the argument.</ul>
  372. *
  373. * @param a a {@code double} value.
  374. * @return the closest floating-point value to {@code a} that is
  375. * equal to a mathematical integer.
  376. */
  377. @:overload public static function rint(a : Float) : Float;
  378. /**
  379. * Returns the angle <i>theta</i> from the conversion of rectangular
  380. * coordinates ({@code x},&nbsp;{@code y}) to polar
  381. * coordinates (r,&nbsp;<i>theta</i>).
  382. * This method computes the phase <i>theta</i> by computing an arc tangent
  383. * of {@code y/x} in the range of -<i>pi</i> to <i>pi</i>. Special
  384. * cases:
  385. * <ul><li>If either argument is NaN, then the result is NaN.
  386. * <li>If the first argument is positive zero and the second argument
  387. * is positive, or the first argument is positive and finite and the
  388. * second argument is positive infinity, then the result is positive
  389. * zero.
  390. * <li>If the first argument is negative zero and the second argument
  391. * is positive, or the first argument is negative and finite and the
  392. * second argument is positive infinity, then the result is negative zero.
  393. * <li>If the first argument is positive zero and the second argument
  394. * is negative, or the first argument is positive and finite and the
  395. * second argument is negative infinity, then the result is the
  396. * {@code double} value closest to <i>pi</i>.
  397. * <li>If the first argument is negative zero and the second argument
  398. * is negative, or the first argument is negative and finite and the
  399. * second argument is negative infinity, then the result is the
  400. * {@code double} value closest to -<i>pi</i>.
  401. * <li>If the first argument is positive and the second argument is
  402. * positive zero or negative zero, or the first argument is positive
  403. * infinity and the second argument is finite, then the result is the
  404. * {@code double} value closest to <i>pi</i>/2.
  405. * <li>If the first argument is negative and the second argument is
  406. * positive zero or negative zero, or the first argument is negative
  407. * infinity and the second argument is finite, then the result is the
  408. * {@code double} value closest to -<i>pi</i>/2.
  409. * <li>If both arguments are positive infinity, then the result is the
  410. * {@code double} value closest to <i>pi</i>/4.
  411. * <li>If the first argument is positive infinity and the second argument
  412. * is negative infinity, then the result is the {@code double}
  413. * value closest to 3*<i>pi</i>/4.
  414. * <li>If the first argument is negative infinity and the second argument
  415. * is positive infinity, then the result is the {@code double} value
  416. * closest to -<i>pi</i>/4.
  417. * <li>If both arguments are negative infinity, then the result is the
  418. * {@code double} value closest to -3*<i>pi</i>/4.</ul>
  419. *
  420. * <p>The computed result must be within 2 ulps of the exact result.
  421. * Results must be semi-monotonic.
  422. *
  423. * @param y the ordinate coordinate
  424. * @param x the abscissa coordinate
  425. * @return the <i>theta</i> component of the point
  426. * (<i>r</i>,&nbsp;<i>theta</i>)
  427. * in polar coordinates that corresponds to the point
  428. * (<i>x</i>,&nbsp;<i>y</i>) in Cartesian coordinates.
  429. */
  430. @:overload public static function atan2(y : Float, x : Float) : Float;
  431. /**
  432. * Returns the value of the first argument raised to the power of the
  433. * second argument. Special cases:
  434. *
  435. * <ul><li>If the second argument is positive or negative zero, then the
  436. * result is 1.0.
  437. * <li>If the second argument is 1.0, then the result is the same as the
  438. * first argument.
  439. * <li>If the second argument is NaN, then the result is NaN.
  440. * <li>If the first argument is NaN and the second argument is nonzero,
  441. * then the result is NaN.
  442. *
  443. * <li>If
  444. * <ul>
  445. * <li>the absolute value of the first argument is greater than 1
  446. * and the second argument is positive infinity, or
  447. * <li>the absolute value of the first argument is less than 1 and
  448. * the second argument is negative infinity,
  449. * </ul>
  450. * then the result is positive infinity.
  451. *
  452. * <li>If
  453. * <ul>
  454. * <li>the absolute value of the first argument is greater than 1 and
  455. * the second argument is negative infinity, or
  456. * <li>the absolute value of the
  457. * first argument is less than 1 and the second argument is positive
  458. * infinity,
  459. * </ul>
  460. * then the result is positive zero.
  461. *
  462. * <li>If the absolute value of the first argument equals 1 and the
  463. * second argument is infinite, then the result is NaN.
  464. *
  465. * <li>If
  466. * <ul>
  467. * <li>the first argument is positive zero and the second argument
  468. * is greater than zero, or
  469. * <li>the first argument is positive infinity and the second
  470. * argument is less than zero,
  471. * </ul>
  472. * then the result is positive zero.
  473. *
  474. * <li>If
  475. * <ul>
  476. * <li>the first argument is positive zero and the second argument
  477. * is less than zero, or
  478. * <li>the first argument is positive infinity and the second
  479. * argument is greater than zero,
  480. * </ul>
  481. * then the result is positive infinity.
  482. *
  483. * <li>If
  484. * <ul>
  485. * <li>the first argument is negative zero and the second argument
  486. * is greater than zero but not a finite odd integer, or
  487. * <li>the first argument is negative infinity and the second
  488. * argument is less than zero but not a finite odd integer,
  489. * </ul>
  490. * then the result is positive zero.
  491. *
  492. * <li>If
  493. * <ul>
  494. * <li>the first argument is negative zero and the second argument
  495. * is a positive finite odd integer, or
  496. * <li>the first argument is negative infinity and the second
  497. * argument is a negative finite odd integer,
  498. * </ul>
  499. * then the result is negative zero.
  500. *
  501. * <li>If
  502. * <ul>
  503. * <li>the first argument is negative zero and the second argument
  504. * is less than zero but not a finite odd integer, or
  505. * <li>the first argument is negative infinity and the second
  506. * argument is greater than zero but not a finite odd integer,
  507. * </ul>
  508. * then the result is positive infinity.
  509. *
  510. * <li>If
  511. * <ul>
  512. * <li>the first argument is negative zero and the second argument
  513. * is a negative finite odd integer, or
  514. * <li>the first argument is negative infinity and the second
  515. * argument is a positive finite odd integer,
  516. * </ul>
  517. * then the result is negative infinity.
  518. *
  519. * <li>If the first argument is finite and less than zero
  520. * <ul>
  521. * <li> if the second argument is a finite even integer, the
  522. * result is equal to the result of raising the absolute value of
  523. * the first argument to the power of the second argument
  524. *
  525. * <li>if the second argument is a finite odd integer, the result
  526. * is equal to the negative of the result of raising the absolute
  527. * value of the first argument to the power of the second
  528. * argument
  529. *
  530. * <li>if the second argument is finite and not an integer, then
  531. * the result is NaN.
  532. * </ul>
  533. *
  534. * <li>If both arguments are integers, then the result is exactly equal
  535. * to the mathematical result of raising the first argument to the power
  536. * of the second argument if that result can in fact be represented
  537. * exactly as a {@code double} value.</ul>
  538. *
  539. * <p>(In the foregoing descriptions, a floating-point value is
  540. * considered to be an integer if and only if it is finite and a
  541. * fixed point of the method {@link #ceil ceil} or,
  542. * equivalently, a fixed point of the method {@link #floor
  543. * floor}. A value is a fixed point of a one-argument
  544. * method if and only if the result of applying the method to the
  545. * value is equal to the value.)
  546. *
  547. * <p>The computed result must be within 1 ulp of the exact result.
  548. * Results must be semi-monotonic.
  549. *
  550. * @param a the base.
  551. * @param b the exponent.
  552. * @return the value {@code a}<sup>{@code b}</sup>.
  553. */
  554. @:overload public static function pow(a : Float, b : Float) : Float;
  555. /**
  556. * Returns the closest {@code int} to the argument, with ties
  557. * rounding up.
  558. *
  559. * <p>
  560. * Special cases:
  561. * <ul><li>If the argument is NaN, the result is 0.
  562. * <li>If the argument is negative infinity or any value less than or
  563. * equal to the value of {@code Integer.MIN_VALUE}, the result is
  564. * equal to the value of {@code Integer.MIN_VALUE}.
  565. * <li>If the argument is positive infinity or any value greater than or
  566. * equal to the value of {@code Integer.MAX_VALUE}, the result is
  567. * equal to the value of {@code Integer.MAX_VALUE}.</ul>
  568. *
  569. * @param a a floating-point value to be rounded to an integer.
  570. * @return the value of the argument rounded to the nearest
  571. * {@code int} value.
  572. * @see java.lang.Integer#MAX_VALUE
  573. * @see java.lang.Integer#MIN_VALUE
  574. */
  575. @:overload public static function round(a : Single) : Int;
  576. /**
  577. * Returns the closest {@code long} to the argument, with ties
  578. * rounding up.
  579. *
  580. * <p>Special cases:
  581. * <ul><li>If the argument is NaN, the result is 0.
  582. * <li>If the argument is negative infinity or any value less than or
  583. * equal to the value of {@code Long.MIN_VALUE}, the result is
  584. * equal to the value of {@code Long.MIN_VALUE}.
  585. * <li>If the argument is positive infinity or any value greater than or
  586. * equal to the value of {@code Long.MAX_VALUE}, the result is
  587. * equal to the value of {@code Long.MAX_VALUE}.</ul>
  588. *
  589. * @param a a floating-point value to be rounded to a
  590. * {@code long}.
  591. * @return the value of the argument rounded to the nearest
  592. * {@code long} value.
  593. * @see java.lang.Long#MAX_VALUE
  594. * @see java.lang.Long#MIN_VALUE
  595. */
  596. @:overload public static function round(a : Float) : haxe.Int64;
  597. /**
  598. * Returns a {@code double} value with a positive sign, greater
  599. * than or equal to {@code 0.0} and less than {@code 1.0}.
  600. * Returned values are chosen pseudorandomly with (approximately)
  601. * uniform distribution from that range.
  602. *
  603. * <p>When this method is first called, it creates a single new
  604. * pseudorandom-number generator, exactly as if by the expression
  605. *
  606. * <blockquote>{@code new java.util.Random()}</blockquote>
  607. *
  608. * This new pseudorandom-number generator is used thereafter for
  609. * all calls to this method and is used nowhere else.
  610. *
  611. * <p>This method is properly synchronized to allow correct use by
  612. * more than one thread. However, if many threads need to generate
  613. * pseudorandom numbers at a great rate, it may reduce contention
  614. * for each thread to have its own pseudorandom-number generator.
  615. *
  616. * @return a pseudorandom {@code double} greater than or equal
  617. * to {@code 0.0} and less than {@code 1.0}.
  618. * @see Random#nextDouble()
  619. */
  620. @:overload public static function random() : Float;
  621. /**
  622. * Returns the absolute value of an {@code int} value.
  623. * If the argument is not negative, the argument is returned.
  624. * If the argument is negative, the negation of the argument is returned.
  625. *
  626. * <p>Note that if the argument is equal to the value of
  627. * {@link Integer#MIN_VALUE}, the most negative representable
  628. * {@code int} value, the result is that same value, which is
  629. * negative.
  630. *
  631. * @param a the argument whose absolute value is to be determined
  632. * @return the absolute value of the argument.
  633. */
  634. @:overload public static function abs(a : Int) : Int;
  635. /**
  636. * Returns the absolute value of a {@code long} value.
  637. * If the argument is not negative, the argument is returned.
  638. * If the argument is negative, the negation of the argument is returned.
  639. *
  640. * <p>Note that if the argument is equal to the value of
  641. * {@link Long#MIN_VALUE}, the most negative representable
  642. * {@code long} value, the result is that same value, which
  643. * is negative.
  644. *
  645. * @param a the argument whose absolute value is to be determined
  646. * @return the absolute value of the argument.
  647. */
  648. @:overload public static function abs(a : haxe.Int64) : haxe.Int64;
  649. /**
  650. * Returns the absolute value of a {@code float} value.
  651. * If the argument is not negative, the argument is returned.
  652. * If the argument is negative, the negation of the argument is returned.
  653. * Special cases:
  654. * <ul><li>If the argument is positive zero or negative zero, the
  655. * result is positive zero.
  656. * <li>If the argument is infinite, the result is positive infinity.
  657. * <li>If the argument is NaN, the result is NaN.</ul>
  658. * In other words, the result is the same as the value of the expression:
  659. * <p>{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
  660. *
  661. * @param a the argument whose absolute value is to be determined
  662. * @return the absolute value of the argument.
  663. */
  664. @:overload public static function abs(a : Single) : Single;
  665. /**
  666. * Returns the absolute value of a {@code double} value.
  667. * If the argument is not negative, the argument is returned.
  668. * If the argument is negative, the negation of the argument is returned.
  669. * Special cases:
  670. * <ul><li>If the argument is positive zero or negative zero, the result
  671. * is positive zero.
  672. * <li>If the argument is infinite, the result is positive infinity.
  673. * <li>If the argument is NaN, the result is NaN.</ul>
  674. * In other words, the result is the same as the value of the expression:
  675. * <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
  676. *
  677. * @param a the argument whose absolute value is to be determined
  678. * @return the absolute value of the argument.
  679. */
  680. @:overload public static function abs(a : Float) : Float;
  681. /**
  682. * Returns the greater of two {@code int} values. That is, the
  683. * result is the argument closer to the value of
  684. * {@link Integer#MAX_VALUE}. If the arguments have the same value,
  685. * the result is that same value.
  686. *
  687. * @param a an argument.
  688. * @param b another argument.
  689. * @return the larger of {@code a} and {@code b}.
  690. */
  691. @:overload public static function max(a : Int, b : Int) : Int;
  692. /**
  693. * Returns the greater of two {@code long} values. That is, the
  694. * result is the argument closer to the value of
  695. * {@link Long#MAX_VALUE}. If the arguments have the same value,
  696. * the result is that same value.
  697. *
  698. * @param a an argument.
  699. * @param b another argument.
  700. * @return the larger of {@code a} and {@code b}.
  701. */
  702. @:overload public static function max(a : haxe.Int64, b : haxe.Int64) : haxe.Int64;
  703. /**
  704. * Returns the greater of two {@code float} values. That is,
  705. * the result is the argument closer to positive infinity. If the
  706. * arguments have the same value, the result is that same
  707. * value. If either value is NaN, then the result is NaN. Unlike
  708. * the numerical comparison operators, this method considers
  709. * negative zero to be strictly smaller than positive zero. If one
  710. * argument is positive zero and the other negative zero, the
  711. * result is positive zero.
  712. *
  713. * @param a an argument.
  714. * @param b another argument.
  715. * @return the larger of {@code a} and {@code b}.
  716. */
  717. @:overload public static function max(a : Single, b : Single) : Single;
  718. /**
  719. * Returns the greater of two {@code double} values. That
  720. * is, the result is the argument closer to positive infinity. If
  721. * the arguments have the same value, the result is that same
  722. * value. If either value is NaN, then the result is NaN. Unlike
  723. * the numerical comparison operators, this method considers
  724. * negative zero to be strictly smaller than positive zero. If one
  725. * argument is positive zero and the other negative zero, the
  726. * result is positive zero.
  727. *
  728. * @param a an argument.
  729. * @param b another argument.
  730. * @return the larger of {@code a} and {@code b}.
  731. */
  732. @:overload public static function max(a : Float, b : Float) : Float;
  733. /**
  734. * Returns the smaller of two {@code int} values. That is,
  735. * the result the argument closer to the value of
  736. * {@link Integer#MIN_VALUE}. If the arguments have the same
  737. * value, the result is that same value.
  738. *
  739. * @param a an argument.
  740. * @param b another argument.
  741. * @return the smaller of {@code a} and {@code b}.
  742. */
  743. @:overload public static function min(a : Int, b : Int) : Int;
  744. /**
  745. * Returns the smaller of two {@code long} values. That is,
  746. * the result is the argument closer to the value of
  747. * {@link Long#MIN_VALUE}. If the arguments have the same
  748. * value, the result is that same value.
  749. *
  750. * @param a an argument.
  751. * @param b another argument.
  752. * @return the smaller of {@code a} and {@code b}.
  753. */
  754. @:overload public static function min(a : haxe.Int64, b : haxe.Int64) : haxe.Int64;
  755. /**
  756. * Returns the smaller of two {@code float} values. That is,
  757. * the result is the value closer to negative infinity. If the
  758. * arguments have the same value, the result is that same
  759. * value. If either value is NaN, then the result is NaN. Unlike
  760. * the numerical comparison operators, this method considers
  761. * negative zero to be strictly smaller than positive zero. If
  762. * one argument is positive zero and the other is negative zero,
  763. * the result is negative zero.
  764. *
  765. * @param a an argument.
  766. * @param b another argument.
  767. * @return the smaller of {@code a} and {@code b}.
  768. */
  769. @:overload public static function min(a : Single, b : Single) : Single;
  770. /**
  771. * Returns the smaller of two {@code double} values. That
  772. * is, the result is the value closer to negative infinity. If the
  773. * arguments have the same value, the result is that same
  774. * value. If either value is NaN, then the result is NaN. Unlike
  775. * the numerical comparison operators, this method considers
  776. * negative zero to be strictly smaller than positive zero. If one
  777. * argument is positive zero and the other is negative zero, the
  778. * result is negative zero.
  779. *
  780. * @param a an argument.
  781. * @param b another argument.
  782. * @return the smaller of {@code a} and {@code b}.
  783. */
  784. @:overload public static function min(a : Float, b : Float) : Float;
  785. /**
  786. * Returns the size of an ulp of the argument. An ulp of a
  787. * {@code double} value is the positive distance between this
  788. * floating-point value and the {@code double} value next
  789. * larger in magnitude. Note that for non-NaN <i>x</i>,
  790. * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
  791. *
  792. * <p>Special Cases:
  793. * <ul>
  794. * <li> If the argument is NaN, then the result is NaN.
  795. * <li> If the argument is positive or negative infinity, then the
  796. * result is positive infinity.
  797. * <li> If the argument is positive or negative zero, then the result is
  798. * {@code Double.MIN_VALUE}.
  799. * <li> If the argument is &plusmn;{@code Double.MAX_VALUE}, then
  800. * the result is equal to 2<sup>971</sup>.
  801. * </ul>
  802. *
  803. * @param d the floating-point value whose ulp is to be returned
  804. * @return the size of an ulp of the argument
  805. * @author Joseph D. Darcy
  806. * @since 1.5
  807. */
  808. @:require(java5) @:overload public static function ulp(d : Float) : Float;
  809. /**
  810. * Returns the size of an ulp of the argument. An ulp of a
  811. * {@code float} value is the positive distance between this
  812. * floating-point value and the {@code float} value next
  813. * larger in magnitude. Note that for non-NaN <i>x</i>,
  814. * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
  815. *
  816. * <p>Special Cases:
  817. * <ul>
  818. * <li> If the argument is NaN, then the result is NaN.
  819. * <li> If the argument is positive or negative infinity, then the
  820. * result is positive infinity.
  821. * <li> If the argument is positive or negative zero, then the result is
  822. * {@code Float.MIN_VALUE}.
  823. * <li> If the argument is &plusmn;{@code Float.MAX_VALUE}, then
  824. * the result is equal to 2<sup>104</sup>.
  825. * </ul>
  826. *
  827. * @param f the floating-point value whose ulp is to be returned
  828. * @return the size of an ulp of the argument
  829. * @author Joseph D. Darcy
  830. * @since 1.5
  831. */
  832. @:require(java5) @:overload public static function ulp(f : Single) : Single;
  833. /**
  834. * Returns the signum function of the argument; zero if the argument
  835. * is zero, 1.0 if the argument is greater than zero, -1.0 if the
  836. * argument is less than zero.
  837. *
  838. * <p>Special Cases:
  839. * <ul>
  840. * <li> If the argument is NaN, then the result is NaN.
  841. * <li> If the argument is positive zero or negative zero, then the
  842. * result is the same as the argument.
  843. * </ul>
  844. *
  845. * @param d the floating-point value whose signum is to be returned
  846. * @return the signum function of the argument
  847. * @author Joseph D. Darcy
  848. * @since 1.5
  849. */
  850. @:require(java5) @:overload public static function signum(d : Float) : Float;
  851. /**
  852. * Returns the signum function of the argument; zero if the argument
  853. * is zero, 1.0f if the argument is greater than zero, -1.0f if the
  854. * argument is less than zero.
  855. *
  856. * <p>Special Cases:
  857. * <ul>
  858. * <li> If the argument is NaN, then the result is NaN.
  859. * <li> If the argument is positive zero or negative zero, then the
  860. * result is the same as the argument.
  861. * </ul>
  862. *
  863. * @param f the floating-point value whose signum is to be returned
  864. * @return the signum function of the argument
  865. * @author Joseph D. Darcy
  866. * @since 1.5
  867. */
  868. @:require(java5) @:overload public static function signum(f : Single) : Single;
  869. /**
  870. * Returns the hyperbolic sine of a {@code double} value.
  871. * The hyperbolic sine of <i>x</i> is defined to be
  872. * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/2
  873. * where <i>e</i> is {@linkplain Math#E Euler's number}.
  874. *
  875. * <p>Special cases:
  876. * <ul>
  877. *
  878. * <li>If the argument is NaN, then the result is NaN.
  879. *
  880. * <li>If the argument is infinite, then the result is an infinity
  881. * with the same sign as the argument.
  882. *
  883. * <li>If the argument is zero, then the result is a zero with the
  884. * same sign as the argument.
  885. *
  886. * </ul>
  887. *
  888. * <p>The computed result must be within 2.5 ulps of the exact result.
  889. *
  890. * @param x The number whose hyperbolic sine is to be returned.
  891. * @return The hyperbolic sine of {@code x}.
  892. * @since 1.5
  893. */
  894. @:require(java5) @:overload public static function sinh(x : Float) : Float;
  895. /**
  896. * Returns the hyperbolic cosine of a {@code double} value.
  897. * The hyperbolic cosine of <i>x</i> is defined to be
  898. * (<i>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></i>)/2
  899. * where <i>e</i> is {@linkplain Math#E Euler's number}.
  900. *
  901. * <p>Special cases:
  902. * <ul>
  903. *
  904. * <li>If the argument is NaN, then the result is NaN.
  905. *
  906. * <li>If the argument is infinite, then the result is positive
  907. * infinity.
  908. *
  909. * <li>If the argument is zero, then the result is {@code 1.0}.
  910. *
  911. * </ul>
  912. *
  913. * <p>The computed result must be within 2.5 ulps of the exact result.
  914. *
  915. * @param x The number whose hyperbolic cosine is to be returned.
  916. * @return The hyperbolic cosine of {@code x}.
  917. * @since 1.5
  918. */
  919. @:require(java5) @:overload public static function cosh(x : Float) : Float;
  920. /**
  921. * Returns the hyperbolic tangent of a {@code double} value.
  922. * The hyperbolic tangent of <i>x</i> is defined to be
  923. * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/(<i>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></i>),
  924. * in other words, {@linkplain Math#sinh
  925. * sinh(<i>x</i>)}/{@linkplain Math#cosh cosh(<i>x</i>)}. Note
  926. * that the absolute value of the exact tanh is always less than
  927. * 1.
  928. *
  929. * <p>Special cases:
  930. * <ul>
  931. *
  932. * <li>If the argument is NaN, then the result is NaN.
  933. *
  934. * <li>If the argument is zero, then the result is a zero with the
  935. * same sign as the argument.
  936. *
  937. * <li>If the argument is positive infinity, then the result is
  938. * {@code +1.0}.
  939. *
  940. * <li>If the argument is negative infinity, then the result is
  941. * {@code -1.0}.
  942. *
  943. * </ul>
  944. *
  945. * <p>The computed result must be within 2.5 ulps of the exact result.
  946. * The result of {@code tanh} for any finite input must have
  947. * an absolute value less than or equal to 1. Note that once the
  948. * exact result of tanh is within 1/2 of an ulp of the limit value
  949. * of &plusmn;1, correctly signed &plusmn;{@code 1.0} should
  950. * be returned.
  951. *
  952. * @param x The number whose hyperbolic tangent is to be returned.
  953. * @return The hyperbolic tangent of {@code x}.
  954. * @since 1.5
  955. */
  956. @:require(java5) @:overload public static function tanh(x : Float) : Float;
  957. /**
  958. * Returns sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>)
  959. * without intermediate overflow or underflow.
  960. *
  961. * <p>Special cases:
  962. * <ul>
  963. *
  964. * <li> If either argument is infinite, then the result
  965. * is positive infinity.
  966. *
  967. * <li> If either argument is NaN and neither argument is infinite,
  968. * then the result is NaN.
  969. *
  970. * </ul>
  971. *
  972. * <p>The computed result must be within 1 ulp of the exact
  973. * result. If one parameter is held constant, the results must be
  974. * semi-monotonic in the other parameter.
  975. *
  976. * @param x a value
  977. * @param y a value
  978. * @return sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>)
  979. * without intermediate overflow or underflow
  980. * @since 1.5
  981. */
  982. @:require(java5) @:overload public static function hypot(x : Float, y : Float) : Float;
  983. /**
  984. * Returns <i>e</i><sup>x</sup>&nbsp;-1. Note that for values of
  985. * <i>x</i> near 0, the exact sum of
  986. * {@code expm1(x)}&nbsp;+&nbsp;1 is much closer to the true
  987. * result of <i>e</i><sup>x</sup> than {@code exp(x)}.
  988. *
  989. * <p>Special cases:
  990. * <ul>
  991. * <li>If the argument is NaN, the result is NaN.
  992. *
  993. * <li>If the argument is positive infinity, then the result is
  994. * positive infinity.
  995. *
  996. * <li>If the argument is negative infinity, then the result is
  997. * -1.0.
  998. *
  999. * <li>If the argument is zero, then the result is a zero with the
  1000. * same sign as the argument.
  1001. *
  1002. * </ul>
  1003. *
  1004. * <p>The computed result must be within 1 ulp of the exact result.
  1005. * Results must be semi-monotonic. The result of
  1006. * {@code expm1} for any finite input must be greater than or
  1007. * equal to {@code -1.0}. Note that once the exact result of
  1008. * <i>e</i><sup>{@code x}</sup>&nbsp;-&nbsp;1 is within 1/2
  1009. * ulp of the limit value -1, {@code -1.0} should be
  1010. * returned.
  1011. *
  1012. * @param x the exponent to raise <i>e</i> to in the computation of
  1013. * <i>e</i><sup>{@code x}</sup>&nbsp;-1.
  1014. * @return the value <i>e</i><sup>{@code x}</sup>&nbsp;-&nbsp;1.
  1015. * @since 1.5
  1016. */
  1017. @:require(java5) @:overload public static function expm1(x : Float) : Float;
  1018. /**
  1019. * Returns the natural logarithm of the sum of the argument and 1.
  1020. * Note that for small values {@code x}, the result of
  1021. * {@code log1p(x)} is much closer to the true result of ln(1
  1022. * + {@code x}) than the floating-point evaluation of
  1023. * {@code log(1.0+x)}.
  1024. *
  1025. * <p>Special cases:
  1026. *
  1027. * <ul>
  1028. *
  1029. * <li>If the argument is NaN or less than -1, then the result is
  1030. * NaN.
  1031. *
  1032. * <li>If the argument is positive infinity, then the result is
  1033. * positive infinity.
  1034. *
  1035. * <li>If the argument is negative one, then the result is
  1036. * negative infinity.
  1037. *
  1038. * <li>If the argument is zero, then the result is a zero with the
  1039. * same sign as the argument.
  1040. *
  1041. * </ul>
  1042. *
  1043. * <p>The computed result must be within 1 ulp of the exact result.
  1044. * Results must be semi-monotonic.
  1045. *
  1046. * @param x a value
  1047. * @return the value ln({@code x}&nbsp;+&nbsp;1), the natural
  1048. * log of {@code x}&nbsp;+&nbsp;1
  1049. * @since 1.5
  1050. */
  1051. @:require(java5) @:overload public static function log1p(x : Float) : Float;
  1052. /**
  1053. * Returns the first floating-point argument with the sign of the
  1054. * second floating-point argument. Note that unlike the {@link
  1055. * StrictMath#copySign(double, double) StrictMath.copySign}
  1056. * method, this method does not require NaN {@code sign}
  1057. * arguments to be treated as positive values; implementations are
  1058. * permitted to treat some NaN arguments as positive and other NaN
  1059. * arguments as negative to allow greater performance.
  1060. *
  1061. * @param magnitude the parameter providing the magnitude of the result
  1062. * @param sign the parameter providing the sign of the result
  1063. * @return a value with the magnitude of {@code magnitude}
  1064. * and the sign of {@code sign}.
  1065. * @since 1.6
  1066. */
  1067. @:require(java6) @:overload public static function copySign(magnitude : Float, sign : Float) : Float;
  1068. /**
  1069. * Returns the first floating-point argument with the sign of the
  1070. * second floating-point argument. Note that unlike the {@link
  1071. * StrictMath#copySign(float, float) StrictMath.copySign}
  1072. * method, this method does not require NaN {@code sign}
  1073. * arguments to be treated as positive values; implementations are
  1074. * permitted to treat some NaN arguments as positive and other NaN
  1075. * arguments as negative to allow greater performance.
  1076. *
  1077. * @param magnitude the parameter providing the magnitude of the result
  1078. * @param sign the parameter providing the sign of the result
  1079. * @return a value with the magnitude of {@code magnitude}
  1080. * and the sign of {@code sign}.
  1081. * @since 1.6
  1082. */
  1083. @:require(java6) @:overload public static function copySign(magnitude : Single, sign : Single) : Single;
  1084. /**
  1085. * Returns the unbiased exponent used in the representation of a
  1086. * {@code float}. Special cases:
  1087. *
  1088. * <ul>
  1089. * <li>If the argument is NaN or infinite, then the result is
  1090. * {@link Float#MAX_EXPONENT} + 1.
  1091. * <li>If the argument is zero or subnormal, then the result is
  1092. * {@link Float#MIN_EXPONENT} -1.
  1093. * </ul>
  1094. * @param f a {@code float} value
  1095. * @return the unbiased exponent of the argument
  1096. * @since 1.6
  1097. */
  1098. @:require(java6) @:overload public static function getExponent(f : Single) : Int;
  1099. /**
  1100. * Returns the unbiased exponent used in the representation of a
  1101. * {@code double}. Special cases:
  1102. *
  1103. * <ul>
  1104. * <li>If the argument is NaN or infinite, then the result is
  1105. * {@link Double#MAX_EXPONENT} + 1.
  1106. * <li>If the argument is zero or subnormal, then the result is
  1107. * {@link Double#MIN_EXPONENT} -1.
  1108. * </ul>
  1109. * @param d a {@code double} value
  1110. * @return the unbiased exponent of the argument
  1111. * @since 1.6
  1112. */
  1113. @:require(java6) @:overload public static function getExponent(d : Float) : Int;
  1114. /**
  1115. * Returns the floating-point number adjacent to the first
  1116. * argument in the direction of the second argument. If both
  1117. * arguments compare as equal the second argument is returned.
  1118. *
  1119. * <p>
  1120. * Special cases:
  1121. * <ul>
  1122. * <li> If either argument is a NaN, then NaN is returned.
  1123. *
  1124. * <li> If both arguments are signed zeros, {@code direction}
  1125. * is returned unchanged (as implied by the requirement of
  1126. * returning the second argument if the arguments compare as
  1127. * equal).
  1128. *
  1129. * <li> If {@code start} is
  1130. * &plusmn;{@link Double#MIN_VALUE} and {@code direction}
  1131. * has a value such that the result should have a smaller
  1132. * magnitude, then a zero with the same sign as {@code start}
  1133. * is returned.
  1134. *
  1135. * <li> If {@code start} is infinite and
  1136. * {@code direction} has a value such that the result should
  1137. * have a smaller magnitude, {@link Double#MAX_VALUE} with the
  1138. * same sign as {@code start} is returned.
  1139. *
  1140. * <li> If {@code start} is equal to &plusmn;
  1141. * {@link Double#MAX_VALUE} and {@code direction} has a
  1142. * value such that the result should have a larger magnitude, an
  1143. * infinity with same sign as {@code start} is returned.
  1144. * </ul>
  1145. *
  1146. * @param start starting floating-point value
  1147. * @param direction value indicating which of
  1148. * {@code start}'s neighbors or {@code start} should
  1149. * be returned
  1150. * @return The floating-point number adjacent to {@code start} in the
  1151. * direction of {@code direction}.
  1152. * @since 1.6
  1153. */
  1154. @:require(java6) @:overload public static function nextAfter(start : Float, direction : Float) : Float;
  1155. /**
  1156. * Returns the floating-point number adjacent to the first
  1157. * argument in the direction of the second argument. If both
  1158. * arguments compare as equal a value equivalent to the second argument
  1159. * is returned.
  1160. *
  1161. * <p>
  1162. * Special cases:
  1163. * <ul>
  1164. * <li> If either argument is a NaN, then NaN is returned.
  1165. *
  1166. * <li> If both arguments are signed zeros, a value equivalent
  1167. * to {@code direction} is returned.
  1168. *
  1169. * <li> If {@code start} is
  1170. * &plusmn;{@link Float#MIN_VALUE} and {@code direction}
  1171. * has a value such that the result should have a smaller
  1172. * magnitude, then a zero with the same sign as {@code start}
  1173. * is returned.
  1174. *
  1175. * <li> If {@code start} is infinite and
  1176. * {@code direction} has a value such that the result should
  1177. * have a smaller magnitude, {@link Float#MAX_VALUE} with the
  1178. * same sign as {@code start} is returned.
  1179. *
  1180. * <li> If {@code start} is equal to &plusmn;
  1181. * {@link Float#MAX_VALUE} and {@code direction} has a
  1182. * value such that the result should have a larger magnitude, an
  1183. * infinity with same sign as {@code start} is returned.
  1184. * </ul>
  1185. *
  1186. * @param start starting floating-point value
  1187. * @param direction value indicating which of
  1188. * {@code start}'s neighbors or {@code start} should
  1189. * be returned
  1190. * @return The floating-point number adjacent to {@code start} in the
  1191. * direction of {@code direction}.
  1192. * @since 1.6
  1193. */
  1194. @:require(java6) @:overload public static function nextAfter(start : Single, direction : Float) : Single;
  1195. /**
  1196. * Returns the floating-point value adjacent to {@code d} in
  1197. * the direction of positive infinity. This method is
  1198. * semantically equivalent to {@code nextAfter(d,
  1199. * Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
  1200. * implementation may run faster than its equivalent
  1201. * {@code nextAfter} call.
  1202. *
  1203. * <p>Special Cases:
  1204. * <ul>
  1205. * <li> If the argument is NaN, the result is NaN.
  1206. *
  1207. * <li> If the argument is positive infinity, the result is
  1208. * positive infinity.
  1209. *
  1210. * <li> If the argument is zero, the result is
  1211. * {@link Double#MIN_VALUE}
  1212. *
  1213. * </ul>
  1214. *
  1215. * @param d starting floating-point value
  1216. * @return The adjacent floating-point value closer to positive
  1217. * infinity.
  1218. * @since 1.6
  1219. */
  1220. @:require(java6) @:overload public static function nextUp(d : Float) : Float;
  1221. /**
  1222. * Returns the floating-point value adjacent to {@code f} in
  1223. * the direction of positive infinity. This method is
  1224. * semantically equivalent to {@code nextAfter(f,
  1225. * Float.POSITIVE_INFINITY)}; however, a {@code nextUp}
  1226. * implementation may run faster than its equivalent
  1227. * {@code nextAfter} call.
  1228. *
  1229. * <p>Special Cases:
  1230. * <ul>
  1231. * <li> If the argument is NaN, the result is NaN.
  1232. *
  1233. * <li> If the argument is positive infinity, the result is
  1234. * positive infinity.
  1235. *
  1236. * <li> If the argument is zero, the result is
  1237. * {@link Float#MIN_VALUE}
  1238. *
  1239. * </ul>
  1240. *
  1241. * @param f starting floating-point value
  1242. * @return The adjacent floating-point value closer to positive
  1243. * infinity.
  1244. * @since 1.6
  1245. */
  1246. @:require(java6) @:overload public static function nextUp(f : Single) : Single;
  1247. /**
  1248. * Return {@code d} &times;
  1249. * 2<sup>{@code scaleFactor}</sup> rounded as if performed
  1250. * by a single correctly rounded floating-point multiply to a
  1251. * member of the double value set. See the Java
  1252. * Language Specification for a discussion of floating-point
  1253. * value sets. If the exponent of the result is between {@link
  1254. * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
  1255. * answer is calculated exactly. If the exponent of the result
  1256. * would be larger than {@code Double.MAX_EXPONENT}, an
  1257. * infinity is returned. Note that if the result is subnormal,
  1258. * precision may be lost; that is, when {@code scalb(x, n)}
  1259. * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
  1260. * <i>x</i>. When the result is non-NaN, the result has the same
  1261. * sign as {@code d}.
  1262. *
  1263. * <p>Special cases:
  1264. * <ul>
  1265. * <li> If the first argument is NaN, NaN is returned.
  1266. * <li> If the first argument is infinite, then an infinity of the
  1267. * same sign is returned.
  1268. * <li> If the first argument is zero, then a zero of the same
  1269. * sign is returned.
  1270. * </ul>
  1271. *
  1272. * @param d number to be scaled by a power of two.
  1273. * @param scaleFactor power of 2 used to scale {@code d}
  1274. * @return {@code d} &times; 2<sup>{@code scaleFactor}</sup>
  1275. * @since 1.6
  1276. */
  1277. @:require(java6) @:overload public static function scalb(d : Float, scaleFactor : Int) : Float;
  1278. /**
  1279. * Return {@code f} &times;
  1280. * 2<sup>{@code scaleFactor}</sup> rounded as if performed
  1281. * by a single correctly rounded floating-point multiply to a
  1282. * member of the float value set. See the Java
  1283. * Language Specification for a discussion of floating-point
  1284. * value sets. If the exponent of the result is between {@link
  1285. * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
  1286. * answer is calculated exactly. If the exponent of the result
  1287. * would be larger than {@code Float.MAX_EXPONENT}, an
  1288. * infinity is returned. Note that if the result is subnormal,
  1289. * precision may be lost; that is, when {@code scalb(x, n)}
  1290. * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
  1291. * <i>x</i>. When the result is non-NaN, the result has the same
  1292. * sign as {@code f}.
  1293. *
  1294. * <p>Special cases:
  1295. * <ul>
  1296. * <li> If the first argument is NaN, NaN is returned.
  1297. * <li> If the first argument is infinite, then an infinity of the
  1298. * same sign is returned.
  1299. * <li> If the first argument is zero, then a zero of the same
  1300. * sign is returned.
  1301. * </ul>
  1302. *
  1303. * @param f number to be scaled by a power of two.
  1304. * @param scaleFactor power of 2 used to scale {@code f}
  1305. * @return {@code f} &times; 2<sup>{@code scaleFactor}</sup>
  1306. * @since 1.6
  1307. */
  1308. @:require(java6) @:overload public static function scalb(f : Single, scaleFactor : Int) : Single;
  1309. }