JavaScript does make errors when dealing just with integers

Discussion in 'Javascript' started by lorlarz, Aug 19, 2008.

  1. lorlarz

    lorlarz Guest

    Contrary to what one authority in the JavaScript field says:
    JavaScript does make errors when dealing with just with integers.

    This authority (Douglas Crockford.) says:
    "integer arithmetic in floating point [as JS uses] is exact"

    Well, I can prove this is incorrect with this program:
    http://mynichecomputing.com/digitallearning/yourOwn.htm

    This a program that uses only integers, yet comes up short in its
    addition or count
    when used. HERE IS HOW TO DO THE EXPERIMENT AND SEE:

    Without adding on an arbitrary decimal number less than one (I believe
    I use .9) ,
    this program will come up short in its count(addition).
    So, omit that .9 from the program so the program is relying on the
    pure exact
    JavaScript addition. NOW, as a step 2: Set up the program
    for "inventory scoring" by using some sample answers set using the
    procedure
    described for doing so for an inventory (see link on the web page I
    gave you
    the code for, for the directions) -- where an item may count on more
    than
    one scale and several items score each scale up (set up to do some of
    each).
    THEN: Use that scoring system
    in several runs on sets of client answers (samples you also make
    yourself)
    and you will find the count coming up SHORT if you omit my + .9 from
    the code.

    You will find the count short. This would be disasterous in a voting
    machine.
     
    lorlarz, Aug 19, 2008
    #1
    1. Advertising

  2. lorlarz <> writes:

    > Contrary to what one authority in the JavaScript field says:
    > JavaScript does make errors when dealing with just with integers.
    >
    > This authority (Douglas Crockford.) says:
    > "integer arithmetic in floating point [as JS uses] is exact"
    >
    > Well, I can prove this is incorrect with this program:
    > http://mynichecomputing.com/digitallearning/yourOwn.htm
    >
    > This a program that uses only integers, yet comes up short in its
    > addition or count
    > when used. HERE IS HOW TO DO THE EXPERIMENT AND SEE:
    >
    > Without adding on an arbitrary decimal number less than one (I believe
    > I use .9) ,
    > this program will come up short in its count(addition).
    > So, omit that .9 from the program so the program is relying on the
    > pure exact
    > JavaScript addition. NOW, as a step 2: Set up the program
    > for "inventory scoring" by using some sample answers set using the
    > procedure
    > described for doing so for an inventory (see link on the web page I
    > gave you
    > the code for, for the directions) -- where an item may count on more
    > than
    > one scale and several items score each scale up (set up to do some of
    > each).
    > THEN: Use that scoring system
    > in several runs on sets of client answers (samples you also make
    > yourself)
    > and you will find the count coming up SHORT if you omit my + .9 from
    > the code.
    >
    > You will find the count short. This would be disasterous in a voting
    > machine.



    Just in case it escaped you: 0.9 is NOT an integer, so you are NOT
    working with "just integers". We've done this to death.

    See also:

    http://docs.sun.com/source/806-3568/ncg_goldberg.html



    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, Aug 19, 2008
    #2
    1. Advertising

  3. lorlarz

    Stevo Guest

    lorlarz wrote:
    > Contrary to what one authority in the JavaScript field says:
    > JavaScript does make errors when dealing with just with integers.
    > I use .9) ,


    Funny looking integer.
     
    Stevo, Aug 19, 2008
    #3
  4. lorlarz meinte:

    > This a program that uses only integers, yet comes up short in its
    > addition or count
    > when used. HERE IS HOW TO DO THE EXPERIMENT AND SEE:
    > Without adding on an arbitrary decimal number less than one (I believe
    > I use .9)


    You're an idiot. Period. Hit the road!




    --
    http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
    http://web.gregorkofler.com ::: meine JS-Spielwiese
    http://www.image2d.com ::: Bildagentur für den alpinen Raum
     
    Gregor Kofler, Aug 19, 2008
    #4
  5. lorlarz

    lorlarz Guest

    On Aug 19, 2:04 pm, Joost Diepenmaat <> wrote:

    >
    > Just in case it escaped you: 0.9 is NOT an integer, so you are NOT
    > working with "just integers". We've done this to death.
    >


    .9 IS A NEEDED CORRECTION FACTOR AND NOT IN THE PROGRAM THE WAY IT
    **FAILS**.

    The .9 is what has to be added to make the pure integer arithmetic
    stop making
    errors and coming up short. In the experiment, you take it OUT.

    Once you remove the .9, all are integers and the math is supposed to
    be exact,
    and it is not.
     
    lorlarz, Aug 19, 2008
    #5
  6. lorlarz

    lorlarz Guest

    On Aug 19, 2:06 pm, Stevo <> wrote:
    > lorlarz wrote:
    > > Contrary to what one authority in the JavaScript field says:
    > > JavaScript does make errors when dealing with just with integers.
    > > I use .9) ,

    >
    > Funny looking integer.


    Will you jokers try to think and read carefully. You take the .9 OUT
    to see the program fail. It succeeds with the .9 in there. IT IS A
    CORRECTION
    FACTOR THAT SUPPOSEDLY ID NOT NEEDED, BUT IT IS.

    IT FAILS WHEN DOING PURE INTEGER ARITHMETIC WITHOUT THAT .9 Do the
    experiment
    and learn. To do the experiment you TAKE OUT THE .9
     
    lorlarz, Aug 19, 2008
    #6
  7. lorlarz <> writes:

    > On Aug 19, 2:04 pm, Joost Diepenmaat <> wrote:
    >
    >>
    >> Just in case it escaped you: 0.9 is NOT an integer, so you are NOT
    >> working with "just integers". We've done this to death.
    >>

    >
    > .9 IS A NEEDED CORRECTION FACTOR AND NOT IN THE PROGRAM THE WAY IT
    > **FAILS**.
    >
    > The .9 is what has to be added to make the pure integer arithmetic
    > stop making
    > errors and coming up short. In the experiment, you take it OUT.
    >
    > Once you remove the .9, all are integers and the math is supposed to
    > be exact,
    > and it is not.


    Well. how about you bloody well show us the code that demonstrates the
    problem in a concise, well-formatted and clear way. Instead of, you
    know, rambling on incoherently.

    http://www.catb.org/~esr/faqs/smart-questions.html#id306810


    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, Aug 19, 2008
    #7
  8. lorlarz

    lorlarz Guest

    On Aug 19, 2:18 pm, Gregor Kofler <> wrote:
    > lorlarz meinte:
    >
    > > This a program that uses only integers, yet comes up short in its
    > > addition or count
    > > when used.  HERE IS HOW TO DO THE EXPERIMENT AND SEE:
    > > Without adding on an arbitrary decimal number less than one (I believe
    > > I use .9)

    >
    > You're an idiot. Period. Hit the road!
    >
    > --http://photo.gregorkofler.at::: Landschafts- und Reisefotografiehttp://web.gregorkofler.com ::: meine JS-Spielwiesehttp://www.image2d.com     ::: Bildagentur für den alpinen Raum


    No.
     
    lorlarz, Aug 19, 2008
    #8
  9. lorlarz

    lorlarz Guest

    On Aug 19, 2:18 pm, Gregor Kofler <> wrote:
    > lorlarz meinte:
    >
    > > This a program that uses only integers, yet comes up short in its
    > > addition or count
    > > when used.  HERE IS HOW TO DO THE EXPERIMENT AND SEE:
    > > Without adding on an arbitrary decimal number less than one (I believe
    > > I use .9)

    >
    > You're an idiot. Period. Hit the road!
    >
    > --http://photo.gregorkofler.at::: Landschafts- und Reisefotografiehttp://web.gregorkofler.com ::: meine JS-Spielwiesehttp://www.image2d.com     ::: Bildagentur für den alpinen Raum


    Yours is a most unacceptable response to my revealing how authorities
    it
    the field of JavaScript ARE WRONG. You should be thanking me, before
    your
    bank account comes up short.
     
    lorlarz, Aug 19, 2008
    #9
  10. lorlarz

    lorlarz Guest

    On Aug 19, 2:34 pm, Joost Diepenmaat <> wrote:
    > lorlarz <> writes:
    > > On Aug 19, 2:04 pm, Joost Diepenmaat <> wrote:

    >
    > >> Just in case it escaped you: 0.9 is NOT an integer, so you are NOT
    > >> working with "just integers". We've done this to death.

    >
    > > .9 IS A NEEDED CORRECTION FACTOR AND NOT IN THE PROGRAM THE WAY IT
    > > **FAILS**.

    >
    > > The .9 is what has to be added to make the pure integer arithmetic
    > > stop making
    > > errors and coming up short. In the experiment, you take it OUT.

    >
    > > Once you remove the .9, all are integers and the math is supposed to
    > > be exact,
    > > and it is not.

    >
    > Well. how about you bloody well show us the code that demonstrates the
    > problem in a concise, well-formatted and clear way. Instead of, you
    > know, rambling on incoherently.
    >
    > http://www.catb.org/~esr/faqs/smart-questions.html#id306810
    >
    > --
    > Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/- Hide quoted text -
    >
    > - Show quoted text -


    Well, its 100% all mine and I take full responsibility. In contrast:
    What team of
    script kiddie monkeys did you work with for your ajax fiasco?
     
    lorlarz, Aug 19, 2008
    #10
  11. lorlarz

    Stevo Guest

    lorlarz wrote:
    > On Aug 19, 2:06 pm, Stevo <> wrote:
    >> lorlarz wrote:
    >>> Contrary to what one authority in the JavaScript field says:
    >>> JavaScript does make errors when dealing with just with integers.
    >>> I use .9) ,

    >> Funny looking integer.

    >
    > Will you jokers try to think and read carefully.


    I usually stop reading when things start being in capitals - it hurts my
    ears when you shout.

    To be honest though, I don't really care. I'm not going to create a
    voting machine with a scripting language initially designed to tweak web
    pages to make them more interesting.
     
    Stevo, Aug 19, 2008
    #11
  12. lorlarz

    Tim Streater Guest

    In article
    <>,
    lorlarz <> wrote:

    > On Aug 19, 2:18 pm, Gregor Kofler <> wrote:
    > > lorlarz meinte:
    > >
    > > > This a program that uses only integers, yet comes up short in its
    > > > addition or count
    > > > when used.  HERE IS HOW TO DO THE EXPERIMENT AND SEE:
    > > > Without adding on an arbitrary decimal number less than one (I believe
    > > > I use .9)

    > >
    > > You're an idiot. Period. Hit the road!
    > >
    > > --http://photo.gregorkofler.at::: Landschafts- und
    > > Reisefotografiehttp://web.gregorkofler.com ::: meine
    > > JS-Spielwiesehttp://www.image2d.com      ::: Bildagentur für den alpinen
    > > Raum

    >
    > No.


    Well, your example and its accompanying doc was too complex and boring
    for me to want to examine it. You need to reduce its complexity.
     
    Tim Streater, Aug 19, 2008
    #12
  13. "lorlarz" the JS deity thusly spoke:

    > Yours is a most unacceptable response to my revealing how authorities
    > it
    > the field of JavaScript ARE WRONG. You should be thanking me, before
    > your
    > bank account comes up short.


    I'm humbled. Next time you'll tell thy disciples how floats and integers
    *really* work.

    BTW isn't "lorlarz" the name of an orc or perhaps a (yikes!) *troll* in
    some Tolkien book? How appropriate.

    Gregor



    --
    http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
    http://web.gregorkofler.com ::: meine JS-Spielwiese
    http://www.image2d.com ::: Bildagentur für den alpinen Raum
     
    Gregor Kofler, Aug 19, 2008
    #13
  14. lorlarz <> writes:

    > On Aug 19, 2:34 pm, Joost Diepenmaat <> wrote:
    >> lorlarz <> writes:
    >> > On Aug 19, 2:04 pm, Joost Diepenmaat <> wrote:

    >>
    >> >> Just in case it escaped you: 0.9 is NOT an integer, so you are NOT
    >> >> working with "just integers". We've done this to death.

    >>
    >> > .9 IS A NEEDED CORRECTION FACTOR AND NOT IN THE PROGRAM THE WAY IT
    >> > **FAILS**.

    >>
    >> > The .9 is what has to be added to make the pure integer arithmetic
    >> > stop making
    >> > errors and coming up short. In the experiment, you take it OUT.

    >>
    >> > Once you remove the .9, all are integers and the math is supposed to
    >> > be exact,
    >> > and it is not.

    >>
    >> Well. how about you bloody well show us the code that demonstrates the
    >> problem in a concise, well-formatted and clear way. Instead of, you
    >> know, rambling on incoherently.
    >>
    >> http://www.catb.org/~esr/faqs/smart-questions.html#id306810
    >>

    >
    > Well, its 100% all mine and I take full responsibility. In contrast:
    > What team of
    > script kiddie monkeys did you work with for your ajax fiasco?


    I take it that this means you in fact cannot demonstrate the problem
    in any clear fashion.

    Thanks for playing.

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, Aug 19, 2008
    #14
  15. lorlarz

    lorlarz Guest

    On Aug 19, 2:50 pm, Joost Diepenmaat <> wrote:
    > lorlarz <> writes:
    > > On Aug 19, 2:34 pm, Joost Diepenmaat <> wrote:
    > >> lorlarz <> writes:
    > >> > On Aug 19, 2:04 pm, Joost Diepenmaat <> wrote:

    >
    > >> >> Just in case it escaped you: 0.9 is NOT an integer, so you are NOT
    > >> >> working with "just integers". We've done this to death.

    >
    > >> > .9 IS A NEEDED CORRECTION FACTOR AND NOT IN THE PROGRAM THE WAY IT
    > >> > **FAILS**.

    >
    > >> > The .9 is what has to be added to make the pure integer arithmetic
    > >> > stop making
    > >> > errors and coming up short. In the experiment, you take it OUT.

    >
    > >> > Once you remove the .9, all are integers and the math is supposed to
    > >> > be exact,
    > >> > and it is not.

    >
    > >> Well. how about you bloody well show us the code that demonstrates the
    > >> problem in a concise, well-formatted and clear way. Instead of, you
    > >> know, rambling on incoherently.

    >
    > >>http://www.catb.org/~esr/faqs/smart-questions.html#id306810

    >
    > > Well, its 100% all mine and I take full responsibility. In contrast:
    > > What team of
    > > script kiddie monkeys did you work with for your ajax fiasco?

    >
    > I take it that this means you in fact cannot demonstrate the problem
    > in any clear fashion.
    >
    > Thanks for playing.
    >
    > --
    > Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/- Hide quoted text -
    >
    > - Show quoted text -


    Since I laid down the challenge and it was clear and it was not any
    more
    or less than any scientist would want, I assume this means you bow to
    my
    expertise and opinion (by the default of being too lazy to conduct a
    test).

    Until further notice all should assume integer addition in Javascript
    my need
    a slight rounding up to be exact.
     
    lorlarz, Aug 19, 2008
    #15
  16. lorlarz <> writes:

    > Since I laid down the challenge and it was clear and it was not any
    > more
    > or less than any scientist would want, I assume this means you bow to
    > my
    > expertise and opinion (by the default of being too lazy to conduct a
    > test).


    See (again):

    http://www.catb.org/~esr/faqs/smart-questions.html#id306810

    > Until further notice all should assume integer addition in Javascript
    > my need
    > a slight rounding up to be exact.


    That's the stupidest conclusion I've seen you draw all day. You really
    should spend less time messing about with the DOM and more time
    learning about actual programming.

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, Aug 19, 2008
    #16
  17. lorlarz

    lorlarz Guest

    On Aug 19, 3:00 pm, Joost Diepenmaat <> wrote:
    > lorlarz <> writes:
    > > Since I laid down the challenge and it was clear and it was not any
    > > more
    > > or less than any scientist would want, I assume this means you bow to
    > > my
    > > expertise and opinion (by the default of being too lazy to conduct a
    > > test).

    >
    > See (again):
    >
    > http://www.catb.org/~esr/faqs/smart-questions.html#id306810
    >
    > > Until further notice all should assume integer addition in Javascript
    > > my need
    > > a slight rounding up to be exact.

    >
    > That's the stupidest conclusion I've seen you draw all day. You really
    > should spend less time messing about with the DOM and more time
    > learning about actual programming.
    >
    > --
    > Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/


    Well, if my "colleagues" are unwilling to replicate a clear
    experiment, the cautious
    Javasripter (who knows not enough to know otherwise) should believe ME
    and that:
    Until further notice all should assume integer addition in Javascript
    may need a slight rounding up to be exact.

    Good conclusion. By the way, Crockford has been informed of his
    serious
    factual error on the basics. I am sure that must sting. He knows he
    has
    been held to account here.
     
    lorlarz, Aug 19, 2008
    #17
  18. lorlarz

    Stevo Guest

    lorlarz wrote:
    > Since I laid down the challenge and it was clear


    Maybe it was clear in your mind, and looking at that mess of code, it's
    a messy mind. If that's your attempt at stripping the problem down to a
    simple clear example, it falls way short. It shouldn't need lots of
    instructions on what to do.

    Try googling: javascript math inaccuracy
     
    Stevo, Aug 19, 2008
    #18
  19. lorlarz

    lorlarz Guest

    On Aug 19, 2:50 pm, Gregor Kofler <> wrote:
    > "lorlarz" the JS deity thusly spoke:
    >
    > > Yours is a most unacceptable response to my revealing how authorities
    > > it
    > > the field of JavaScript ARE WRONG.   You should be thanking me, before
    > > your
    > > bank account comes up short.

    >
    > I'm humbled. Next time you'll tell thy disciples how floats and integers
    > *really* work.
    >
    > BTW isn't "lorlarz" the name of an orc or perhaps a (yikes!) *troll* in
    > some Tolkien book? How appropriate.
    >
    > Gregor
    >
    > --http://photo.gregorkofler.at::: Landschafts- und Reisefotografiehttp://web.gregorkofler.com ::: meine JS-Spielwiesehttp://www.image2d.com     ::: Bildagentur für den alpinen Raum


    Hard to really label a person a troll who is talking about a
    particular claim
    about a particular experiment in computer science (but that seems to
    escape
    your "sensibilities").
     
    lorlarz, Aug 19, 2008
    #19
  20. lorlarz <> writes:

    > Hard to really label a person a troll who is talking about a
    > particular claim
    > about a particular experiment in computer science (but that seems to
    > escape
    > your "sensibilities").


    It's not: you're a troll.

    *plonk*

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, Aug 19, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,031
    Mark Goldin
    Jan 17, 2004
  2. Paul Moore
    Replies:
    0
    Views:
    300
    Paul Moore
    Nov 21, 2006
  3. Aaron W. LaFramboise
    Replies:
    4
    Views:
    365
  4. Anshu
    Replies:
    5
    Views:
    408
    Howard
    Aug 14, 2006
  5. Saqib Ali
    Replies:
    2
    Views:
    223
    Saqib Ali
    Jan 14, 2011
Loading...

Share This Page