Prev: Protect execution of Javascript
Next: Math.random() and Math.round(Math.random()) andMath.floor(Math.random()*2)
From: John G Harris on 1 May 2010 13:21 On Sat, 1 May 2010 at 02:49:07, in comp.lang.javascript, VK wrote: >On May 1, 1:30�pm, Ry Nohryb <jo...(a)jorgechamorro.com> wrote: <snip> >From the Math.round and Math.floor methods >descriptions: > > https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects >/Math/Round > Returns the value of a number rounded to the nearest integer. > > https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects >/Math/Floor > Returns the largest integer less than or equal to a number. > >I am failing to grasp the exact difference between of them. <snip> In case anyone has been confused by VK here are some facts. round 0.9 is 1.0 floor 0.9 is 0.0 John -- John Harris
From: John G Harris on 1 May 2010 13:25
On Sat, 1 May 2010 at 05:17:38, in comp.lang.javascript, VK wrote: <snip> > return (Math.random() >= 0.5) ? _this : _that; <snip> >Would it be appropriate to correct this in the FAQ <snip> The FAQ is correct already. Would beginners benefit from seeing a slightly faster routine for a special case ? John -- John Harris |