Advertisement
Guest User

Untitled

a guest
Aug 21st, 2012
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. JSBool
  2. js_math_max(JSContext *cx, uintN argc, Value *vp)
  3. {
  4.     jsdouble x, z = js_NegativeInfinity;
  5.     Value *argv;
  6.     uintN i;
  7.  
  8.     if (argc == 0) {
  9.         vp->setDouble(js_NegativeInfinity);
  10.         return JS_TRUE;
  11.     }
  12.     argv = vp + 2;
  13.     for (i = 0; i < argc; i++) {
  14.         if (!ValueToNumber(cx, argv[i], &x))
  15.             return JS_FALSE;
  16.         if (JSDOUBLE_IS_NaN(x)) {
  17.             vp->setDouble(js_NaN);
  18.             return JS_TRUE;
  19.         }
  20.         if (x == 0 && x == z) {
  21.             if (js_copysign(1.0, z) == -1)
  22.                 z = x;
  23.         } else {
  24.             z = (x > z) ? x : z;
  25.         }
  26.     }
  27.     vp->setNumber(z);
  28.     return JS_TRUE;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement