Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

NEED URGENT HELP

Name: edo-chan 2011-12-28 11:11

sup /prog/

Ive asked this everywer already but peopl seem too lame to make even a simple program like so i hope the mighty anon programers of 4chan are more skilled

what im trying to do is to Write a method taking two parameters x and n that computes the nth power of x without using ^ or declaring a new variable inside the method or using Math lib.
and it has to be coded in JAVA (i know it sux but dont ask why i use dat shit)
hep plox!

Name: Anonymous 2011-12-28 18:15

ENTERPRISE QUALITY JAVA


  502       /**
  503        * Returns the value of the first argument raised to the power of the
  504        * second argument. Special cases:
  505        *
  506        * <ul><li>If the second argument is positive or negative zero, then the
  507        * result is 1.0.
  508        * <li>If the second argument is 1.0, then the result is the same as the
  509        * first argument.
  510        * <li>If the second argument is NaN, then the result is NaN.
  511        * <li>If the first argument is NaN and the second argument is nonzero,
  512        * then the result is NaN.
  513        *
  514        * <li>If
  515        * <ul>
  516        * <li>the absolute value of the first argument is greater than 1
  517        * and the second argument is positive infinity, or
  518        * <li>the absolute value of the first argument is less than 1 and
  519        * the second argument is negative infinity,
  520        * </ul>
  521        * then the result is positive infinity.
  522        *
  523        * <li>If
  524        * <ul>
  525        * <li>the absolute value of the first argument is greater than 1 and
  526        * the second argument is negative infinity, or
  527        * <li>the absolute value of the
  528        * first argument is less than 1 and the second argument is positive
  529        * infinity,
  530        * </ul>
  531        * then the result is positive zero.
  532        *
  533        * <li>If the absolute value of the first argument equals 1 and the
  534        * second argument is infinite, then the result is NaN.
  535        *
  536        * <li>If
  537        * <ul>
  538        * <li>the first argument is positive zero and the second argument
  539        * is greater than zero, or
  540        * <li>the first argument is positive infinity and the second
  541        * argument is less than zero,
  542        * </ul>
  543        * then the result is positive zero.
  544        *
  545        * <li>If
  546        * <ul>
  547        * <li>the first argument is positive zero and the second argument
  548        * is less than zero, or
  549        * <li>the first argument is positive infinity and the second
  550        * argument is greater than zero,
  551        * </ul>
  552        * then the result is positive infinity.
  553        *
  554        * <li>If
  555        * <ul>
  556        * <li>the first argument is negative zero and the second argument
  557        * is greater than zero but not a finite odd integer, or
  558        * <li>the first argument is negative infinity and the second
  559        * argument is less than zero but not a finite odd integer,
  560        * </ul>
  561        * then the result is positive zero.
  562        *
  563        * <li>If
  564        * <ul>
  565        * <li>the first argument is negative zero and the second argument
  566        * is a positive finite odd integer, or
  567        * <li>the first argument is negative infinity and the second
  568        * argument is a negative finite odd integer,
  569        * </ul>
  570        * then the result is negative zero.
  571        *
  572        * <li>If
  573        * <ul>
  574        * <li>the first argument is negative zero and the second argument
  575        * is less than zero but not a finite odd integer, or
  576        * <li>the first argument is negative infinity and the second
  577        * argument is greater than zero but not a finite odd integer,
  578        * </ul>
  579        * then the result is positive infinity.
  580        *
  581        * <li>If
  582        * <ul>
  583        * <li>the first argument is negative zero and the second argument
  584        * is a negative finite odd integer, or
  585        * <li>the first argument is negative infinity and the second
  586        * argument is a positive finite odd integer,
  587        * </ul>
  588        * then the result is negative infinity.
  589        *
  590        * <li>If the first argument is finite and less than zero
  591        * <ul>
  592        * <li> if the second argument is a finite even integer, the
  593        * result is equal to the result of raising the absolute value of
  594        * the first argument to the power of the second argument
  595        *
  596        * <li>if the second argument is a finite odd integer, the result
  597        * is equal to the negative of the result of raising the absolute
  598        * value of the first argument to the power of the second
  599        * argument
  600        *
  601        * <li>if the second argument is finite and not an integer, then
  602        * the result is NaN.
  603        * </ul>
  604        *
  605        * <li>If both arguments are integers, then the result is exactly equal
  606        * to the mathematical result of raising the first argument to the power
  607        * of the second argument if that result can in fact be represented
  608        * exactly as a {@code double} value.</ul>
  609        *
  610        * <p>(In the foregoing descriptions, a floating-point value is
  611        * considered to be an integer if and only if it is finite and a
  612        * fixed point of the method {@link #ceil ceil} or,
  613        * equivalently, a fixed point of the method {@link #floor
  614        * floor}. A value is a fixed point of a one-argument
  615        * method if and only if the result of applying the method to the
  616        * value is equal to the value.)
  617        *
  618        * <p>The computed result must be within 1 ulp of the exact result.
  619        * Results must be semi-monotonic.
  620        *
  621        * @param   a   the base.
  622        * @param   b   the exponent.
  623        * @return  the value {@code a}<sup>{@code b}</sup>.
  624        */
  625       public static double pow(double a, double b) {
  626           return StrictMath.pow(a, b); // default impl. delegates to StrictMath
  627       }

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List