473,327 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Solution for Floating-Point Errors

Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.

Jul 23 '07 #1
24 3250
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.
Yes. To make it simpler, multiply each by 1000000 before adding:

8310 + 1 = 8311

Jul 23 '07 #2
On Jul 23, 5:28 pm, David Mark <dmark.cins...@gmail.comwrote:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.

Yes. To make it simpler, multiply each by 1000000 before adding:

8310 + 1 = 8311
very good. thank you.

Jul 23 '07 #3
David Mark said the following on 7/23/2007 5:28 PM:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
>Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.

Yes. To make it simpler, multiply each by 1000000 before adding:

8310 + 1 = 8311
0.00831 + 0.000001 != 8311

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 23 '07 #4
On Jul 23, 6:08 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
David Mark said the following on 7/23/2007 5:28 PM:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.
Yes. To make it simpler, multiply each by 1000000 before adding:
8310 + 1 = 8311

0.00831 + 0.000001 != 8311
To compare the result, as per my post, you have to multiply both sides
of the equation. I don't know how much more explicit I could have
made this and the OP obviously understood.

Jul 23 '07 #5
Lee
David Mark said:
>
On Jul 23, 6:08 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>David Mark said the following on 7/23/2007 5:28 PM:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.
Yes. To make it simpler, multiply each by 1000000 before adding:
8310 + 1 = 8311

0.00831 + 0.000001 != 8311

To compare the result, as per my post, you have to multiply both sides
of the equation. I don't know how much more explicit I could have
made this and the OP obviously understood.
Saying "multiply each ... before adding" suggests that the things
referred to by "each" are also the things that you are adding, so
you certainly could have been much more clear about specifying
that you also have to multiply the comparison target.

How is it obvious that the OP understood? For all we know, he's
currently scratching his head because your solution, which seems
so simple, doesn't work when implemented.
--

Jul 23 '07 #6
How is it obvious that the OP understood?
Let's see: 0.00831 + 0.000001 = 0.008311

(0.00831*1000000) + (0.000001*1000000) == 0.008311/1000000
8310 + 1 = 8311/1000000

thus ==0.008311

What does everyone think? I'd appreciate a better way of handling this
if there is one...
Thanks

Jul 23 '07 #7
On Jul 23, 6:31 pm, Lee <REM0VElbspamt...@cox.netwrote:
David Mark said:


On Jul 23, 6:08 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
David Mark said the following on 7/23/2007 5:28 PM:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.
Yes. To make it simpler, multiply each by 1000000 before adding:
8310 + 1 = 8311
0.00831 + 0.000001 != 8311
To compare the result, as per my post, you have to multiply both sides
of the equation. I don't know how much more explicit I could have
made this and the OP obviously understood.

Saying "multiply each ... before adding" suggests that the things
referred to by "each" are also the things that you are adding, so
Of course they are.
you certainly could have been much more clear about specifying
that you also have to multiply the comparison target.
How much more clear could the example be? It explicitly shows the new
equation.
>
How is it obvious that the OP understood? For all we know, he's
Because he said so. And now two other posters have muddled the issue
and confused him. How do I know that? Read the thread.
currently scratching his head because your solution, which seems
No. Read the thread.
so simple, doesn't work when implemented.
The example equation "works" fine, in that both sides are equal.

Jul 23 '07 #8
David Mark said the following on 7/23/2007 7:24 PM:
On Jul 23, 6:31 pm, Lee <REM0VElbspamt...@cox.netwrote:
>David Mark said:


>>On Jul 23, 6:08 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
David Mark said the following on 7/23/2007 5:28 PM:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
>Is there a good solution for floating-point errors?
>If I got:
>0.00831 + 0.000001 = 0.00831109999999999999
>can I avoid this by a better method than comparing 2 number length
>after decimal point and using toFixed() to match shorter number with
>another one?
>Thanks.
Yes. To make it simpler, multiply each by 1000000 before adding:
8310 + 1 = 8311
0.00831 + 0.000001 != 8311
To compare the result, as per my post, you have to multiply both sides
of the equation. I don't know how much more explicit I could have
made this and the OP obviously understood.
Saying "multiply each ... before adding" suggests that the things
referred to by "each" are also the things that you are adding, so

Of course they are.
>you certainly could have been much more clear about specifying
that you also have to multiply the comparison target.

How much more clear could the example be? It explicitly shows the new
equation.
Answer:

Multiply both of your decimals by 100000 (in this case), add them, then
divide the answer by 100000 to get the decimal back.

You wanted more clear, you got it.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 23 '07 #9
On Jul 23, 7:35 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
David Mark said the following on 7/23/2007 7:24 PM:


On Jul 23, 6:31 pm, Lee <REM0VElbspamt...@cox.netwrote:
David Mark said:
>On Jul 23, 6:08 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
David Mark said the following on 7/23/2007 5:28 PM:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.
Yes. To make it simpler, multiply each by 1000000 before adding:
8310 + 1 = 8311
0.00831 + 0.000001 != 8311
To compare the result, as per my post, you have to multiply both sides
of the equation. I don't know how much more explicit I could have
made this and the OP obviously understood.
Saying "multiply each ... before adding" suggests that the things
referred to by "each" are also the things that you are adding, so
Of course they are.
you certainly could have been much more clear about specifying
that you also have to multiply the comparison target.
How much more clear could the example be? It explicitly shows the new
equation.

Answer:

Multiply both of your decimals by 100000 (in this case), add them, then
divide the answer by 100000 to get the decimal back.
You've done it again. There are six decimal places to shift (in this
case), not five. 100000 != 1000000.

And what the hell does "get the decimal back" mean anyway? Same for
"multiply both of your decimals."
You wanted more clear, you got it.
I didn't want anything. The OP wanted an answer and got it and
followed up to say it worked. Now you have made a real mess of
things.

Jul 24 '07 #10
Lee
David Mark said:
>
On Jul 23, 6:31 pm, Lee <REM0VElbspamt...@cox.netwrote:
>David Mark said:


>On Jul 23, 6:08 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
David Mark said the following on 7/23/2007 5:28 PM:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.
Yes. To make it simpler, multiply each by 1000000 before adding:
8310 + 1 = 8311
>0.00831 + 0.000001 != 8311
>To compare the result, as per my post, you have to multiply both sides
of the equation. I don't know how much more explicit I could have
made this and the OP obviously understood.

Saying "multiply each ... before adding" suggests that the things
referred to by "each" are also the things that you are adding, so

Of course they are.
>you certainly could have been much more clear about specifying
that you also have to multiply the comparison target.

How much more clear could the example be? It explicitly shows the new
equation.
>>
How is it obvious that the OP understood? For all we know, he's

Because he said so. And now two other posters have muddled the issue
and confused him. How do I know that? Read the thread.
You believe that, because a person says he understands your
solution, that he must actually "obviously" understand it?
Clearly you've never been involved in any sort of user support.

Your explanation is incomplete in that it doesn't clearly
specify that, in addition to multiplying each of the addends
before the addition, that you also multiply the value you're
using for comparison. As I said before, "multiply each ...
before adding" leads one to believe that you are talking only
about the numbers that you are adding.
>currently scratching his head because your solution, which seems

No. Read the thread.
>so simple, doesn't work when implemented.

The example equation "works" fine, in that both sides are equal.
Only if you interpret it as you intended, as opposed to how
you described it.
--

Jul 24 '07 #11
Lee
vu******@gmail.com said:
>
>How is it obvious that the OP understood?

Let's see: 0.00831 + 0.000001 = 0.008311

(0.00831*1000000) + (0.000001*1000000) == 0.008311/1000000
8310 + 1 = 8311/1000000

thus ==0.008311
You realize, don't you, that whether or not you actually
did understand it has nothing whatsoever to do with the
question of whether or not it was obvious that you did?
--

Jul 24 '07 #12
On Jul 23, 8:22 pm, Lee <REM0VElbspamt...@cox.netwrote:
David Mark said:


On Jul 23, 6:31 pm, Lee <REM0VElbspamt...@cox.netwrote:
David Mark said:
On Jul 23, 6:08 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
David Mark said the following on 7/23/2007 5:28 PM:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.
Yes. To make it simpler, multiply each by 1000000 before adding:
8310 + 1 = 8311
0.00831 + 0.000001 != 8311
To compare the result, as per my post, you have to multiply both sides
of the equation. I don't know how much more explicit I could have
made this and the OP obviously understood.
Saying "multiply each ... before adding" suggests that the things
referred to by "each" are also the things that you are adding, so
Of course they are.
you certainly could have been much more clear about specifying
that you also have to multiply the comparison target.
How much more clear could the example be? It explicitly shows the new
equation.
How is it obvious that the OP understood? For all we know, he's
Because he said so. And now two other posters have muddled the issue
and confused him. How do I know that? Read the thread.

You believe that, because a person says he understands your
solution, that he must actually "obviously" understand it?
Clearly you've never been involved in any sort of user support.
Clearly you are more interested in me than in helping the OP, who has
long-since "signed off" on the solution.
>
Your explanation is incomplete in that it doesn't clearly
specify that, in addition to multiplying each of the addends
before the addition, that you also multiply the value you're
using for comparison. As I said before, "multiply each ...
before adding" leads one to believe that you are talking only
about the numbers that you are adding.
We're done talking here.

Jul 24 '07 #13
David Mark said the following on 7/23/2007 8:08 PM:
On Jul 23, 7:35 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>David Mark said the following on 7/23/2007 7:24 PM:


>>On Jul 23, 6:31 pm, Lee <REM0VElbspamt...@cox.netwrote:
David Mark said:
On Jul 23, 6:08 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>David Mark said the following on 7/23/2007 5:28 PM:
>>On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
>>>Is there a good solution for floating-point errors?
>>>If I got:
>>>0.00831 + 0.000001 = 0.00831109999999999999
>>>can I avoid this by a better method than comparing 2 number length
>>>after decimal point and using toFixed() to match shorter number with
>>>another one?
>>>Thanks.
>>Yes. To make it simpler, multiply each by 1000000 before adding:
>>8310 + 1 = 8311
>0.00831 + 0.000001 != 8311
To compare the result, as per my post, you have to multiply both sides
of the equation. I don't know how much more explicit I could have
made this and the OP obviously understood.
Saying "multiply each ... before adding" suggests that the things
referred to by "each" are also the things that you are adding, so
Of course they are.
you certainly could have been much more clear about specifying
that you also have to multiply the comparison target.
How much more clear could the example be? It explicitly shows the new
equation.
Answer:

Multiply both of your decimals by 100000 (in this case), add them, then
divide the answer by 100000 to get the decimal back.

You've done it again. There are six decimal places to shift (in this
case), not five. 100000 != 1000000.
You can count. I am impressed. You just cant add.
And what the hell does "get the decimal back" mean anyway? Same for
"multiply both of your decimals."
Word it how you want it. Your code, as originally posted, gave an
incorrect answer. You got corrected. Take it like a man and move on
sonny boy.
>You wanted more clear, you got it.

I didn't want anything.
<quote cite="David Mark in this post">
How much more clear could the example be?
</quote>

You wanted to know how to make the example clearer, I showed you. You
don't like it. I don't care if you like it or not.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 24 '07 #14
Lee
David Mark said:
>
On Jul 23, 8:22 pm, Lee <REM0VElbspamt...@cox.netwrote:
>David Mark said:


>On Jul 23, 6:31 pm, Lee <REM0VElbspamt...@cox.netwrote:
David Mark said:
>On Jul 23, 6:08 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
David Mark said the following on 7/23/2007 5:28 PM:
On Jul 23, 4:35 pm, vunet...@gmail.com wrote:
Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Thanks.
Yes. To make it simpler, multiply each by 1000000 before adding:
8310 + 1 = 8311
>0.00831 + 0.000001 != 8311
>To compare the result, as per my post, you have to multiply both sides
of the equation. I don't know how much more explicit I could have
made this and the OP obviously understood.
>Saying "multiply each ... before adding" suggests that the things
referred to by "each" are also the things that you are adding, so
>Of course they are.
>you certainly could have been much more clear about specifying
that you also have to multiply the comparison target.
>How much more clear could the example be? It explicitly shows the new
equation.
>How is it obvious that the OP understood? For all we know, he's
>Because he said so. And now two other posters have muddled the issue
and confused him. How do I know that? Read the thread.

You believe that, because a person says he understands your
solution, that he must actually "obviously" understand it?
Clearly you've never been involved in any sort of user support.

Clearly you are more interested in me than in helping the OP, who has
long-since "signed off" on the solution.
Welcome to USENET.
--

Jul 24 '07 #15
On Jul 23, 8:44 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
[snip]
>
You can count. I am impressed. You just cant add.
Oddly enough, the original equation posted still balances. Go back
and check it again if you think that has changed.
>
And what the hell does "get the decimal back" mean anyway? Same for
"multiply both of your decimals."

Word it how you want it. Your code, as originally posted, gave an
Word your own posts. And I posted no code. Re-read the post.
incorrect answer. You got corrected. Take it like a man and move on
sonny boy.
You wanted more clear, you got it.
I didn't want anything.

<quote cite="David Mark in this post">
How much more clear could the example be?
</quote>

You wanted to know how to make the example clearer, I showed you. You
Actually, you showed how to make it wrong by a factor of ten.
don't like it. I don't care if you like it or not.
We're done talking here.

Jul 24 '07 #16
David Mark said the following on 7/23/2007 9:31 PM:
On Jul 23, 8:44 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
[snip]
>You can count. I am impressed. You just cant add.

Oddly enough, the original equation posted still balances. Go back
and check it again if you think that has changed.
Who said anything about the original equation with regards to what I
wrote? I said you can count, you just can't add.
>>And what the hell does "get the decimal back" mean anyway? Same for
"multiply both of your decimals."
Word it how you want it. Your code, as originally posted, gave an

Word your own posts. And I posted no code. Re-read the post.
I know what you babbled, and you babbled some incorrect babble that you
are now trying to defend.
>incorrect answer. You got corrected. Take it like a man and move on
sonny boy.
>>>You wanted more clear, you got it.
I didn't want anything.
<quote cite="David Mark in this post">
How much more clear could the example be?
</quote>

You wanted to know how to make the example clearer, I showed you. You

Actually, you showed how to make it wrong by a factor of ten.
::sigh:: You are related to VK aren't you?
>don't like it. I don't care if you like it or not.

We're done talking here.
Who is "talking"? Not me. Do you have some sort of screen reader that
reads to you?

Besides, don't make promises you don't intend to keep.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 24 '07 #17
On Jul 23, 9:31 pm, David Mark <dmark.cins...@gmail.comwrote:
On Jul 23, 8:44 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
[snip]
You can count. I am impressed. You just cant add.

Oddly enough, the original equation posted still balances. Go back
and check it again if you think that has changed.
And what the hell does "get the decimal back" mean anyway? Same for
"multiply both of your decimals."
Word it how you want it. Your code, as originally posted, gave an

Word your own posts. And I posted no code. Re-read the post.
incorrect answer. You got corrected. Take it like a man and move on
sonny boy.
>You wanted more clear, you got it.
I didn't want anything.
<quote cite="David Mark in this post">
How much more clear could the example be?
</quote>
You wanted to know how to make the example clearer, I showed you. You

Actually, you showed how to make it wrong by a factor of ten.
don't like it. I don't care if you like it or not.

We're done talking here.
wow. i am lucky enough to get at least one answer out of 18 replies.
thanks.
PS: should I also add links to my websites in my signature?

Jul 24 '07 #18
Lee
vu******@gmail.com said:
>wow. i am lucky enough to get at least one answer out of 18 replies.
I only see one reply to your question, not 18. The other
posts to this thread were discussing that answer. That's
very normal and desirable. One of the strengths of this
newsgroup is the relative assurance that debatable answers
will be challenged and clarified and/or improved upon.
It doesn't cost you anything, and provides more information
that you can use in deciding whether or not to accept the
suggested solution.
>PS: should I also add links to my websites in my signature?
As a general rule, if you're in the position of asking for
help, you should avoid acting like a jerk. I don't know
why so many people seem to have trouble with that concept.
--

Jul 24 '07 #19
Lee wrote:
vu******@gmail.com said:
>wow. i am lucky enough to get at least one answer out of 18 replies.

I only see one reply to your question, not 18. The other
posts to this thread were discussing that answer. That's
very normal and desirable. One of the strengths of this
newsgroup is the relative assurance that debatable answers
will be challenged and clarified and/or improved upon.
It doesn't cost you anything, and provides more information
that you can use in deciding whether or not to accept the
suggested solution.
>PS: should I also add links to my websites in my signature?

As a general rule, if you're in the position of asking for
help, you should avoid acting like a jerk. I don't know
why so many people seem to have trouble with that concept.

If you aren't a jerk, you probably know the right answer..

Judging by appearance, a visitor from Mars might think that cricket
balls were as edible as apples.

Perhaps, to Martians, they are.

Its a natural human trait to think that your problams are the hard ones,
and stuff you have known since knee high is 'whet everybody (except
jerks)' knows..

Exposure to slightly wider cultural experience will in time disabuse you
of this notion..

It is interesting to note that the following response are *not answers*
to the simple question..e.g.

"How do I get Apache 2.0 working with RedHat 6.0?"

"Upgrade to Fedora core 27 or whatever"
"I'd try Slackware if I were you"
"*There is no compiled suite of Apache 2.0 for Redhat 6.0"
"Only a dork would want to put either of those on a decent computer"
"Apache 2.0 is more full of security holes than Redhat 6.0"
"With a brain like yours, perhaps you had better stick to Windows Vista"
"I don't know., but I wrote my own web server on DOS 2.1 using PHP"
"** why exactly would you want to do this?"
And so on..

*at least this one leads to the most likely correct answer

"You will have to compile the sources and due to the obsolescent nature
of it all, you will largely be on your own"

** and this one at least is a POLITE enquiry as to the context of the
question, rather than an insulting put-down..


Jul 24 '07 #20
Lee
The Natural Philosopher said:
>
Lee wrote:
>vu******@gmail.com said:
>>wow. i am lucky enough to get at least one answer out of 18 replies.

I only see one reply to your question, not 18. The other
posts to this thread were discussing that answer. That's
very normal and desirable. One of the strengths of this
newsgroup is the relative assurance that debatable answers
will be challenged and clarified and/or improved upon.
It doesn't cost you anything, and provides more information
that you can use in deciding whether or not to accept the
suggested solution.
>>PS: should I also add links to my websites in my signature?

As a general rule, if you're in the position of asking for
help, you should avoid acting like a jerk. I don't know
why so many people seem to have trouble with that concept.

If you aren't a jerk, you probably know the right answer..

Judging by appearance, a visitor from Mars might think that cricket
balls were as edible as apples.

Perhaps, to Martians, they are.

Its a natural human trait to think that your problams are the hard ones,
and stuff you have known since knee high is 'whet everybody (except
jerks)' knows..
You seem to have misunderstood my point about being a jerk.
The OP made a lame attempt to insult Randy. That's being
a jerk on several levels.

>It is interesting to note that the following response are *not answers*
to the simple question..e.g.

"How do I get Apache 2.0 working with RedHat 6.0?"

"Upgrade to Fedora core 27 or whatever"
"I'd try Slackware if I were you"
They are not answers to the question, but they may be very
valuable responses to it.

A direct answer to the question "How do I pull the trigger
on my shotgun when the barrel us under my chin" is probably
not the most valuable response.
--

Jul 24 '07 #21
On Jul 24, 11:00 am, Lee <REM0VElbspamt...@cox.netwrote:
The Natural Philosopher said:


Lee wrote:
vunet...@gmail.com said:
>wow. i am lucky enough to get at least one answer out of 18 replies.
I only see one reply to your question, not 18. The other
posts to this thread were discussing that answer. That's
very normal and desirable. One of the strengths of this
newsgroup is the relative assurance that debatable answers
will be challenged and clarified and/or improved upon.
It doesn't cost you anything, and provides more information
that you can use in deciding whether or not to accept the
suggested solution.
>PS: should I also add links to my websites in my signature?
As a general rule, if you're in the position of asking for
help, you should avoid acting like a jerk. I don't know
why so many people seem to have trouble with that concept.
If you aren't a jerk, you probably know the right answer..
Judging by appearance, a visitor from Mars might think that cricket
balls were as edible as apples.
Perhaps, to Martians, they are.
Its a natural human trait to think that your problams are the hard ones,
and stuff you have known since knee high is 'whet everybody (except
jerks)' knows..

You seem to have misunderstood my point about being a jerk.
The OP made a lame attempt to insult Randy. That's being
a jerk on several levels.
It is interesting to note that the following response are *not answers*
to the simple question..e.g.
"How do I get Apache 2.0 working with RedHat 6.0?"
"Upgrade to Fedora core 27 or whatever"
"I'd try Slackware if I were you"

They are not answers to the question, but they may be very
valuable responses to it.

A direct answer to the question "How do I pull the trigger
on my shotgun when the barrel us under my chin" is probably
not the most valuable response.

--
Lee, I see only one person acting as a jerk. It is you.

Jul 24 '07 #22
In comp.lang.javascript message <1185222909.174869.169220@r34g2000hsd.
googlegroups.com>, Mon, 23 Jul 2007 20:35:09, vu******@gmail.com posted:
>Is there a good solution for floating-point errors?
If I got:
0.00831 + 0.000001 = 0.00831109999999999999
can I avoid this by a better method than comparing 2 number length
after decimal point and using toFixed() to match shorter number with
another one?
Before considering what merit previous responses may have, you should
try to understand exactly what is happening.

In the machine, 0.00831 will not be held exactly; I think it is held as
the bit pattern represented in Hex by 3f81 04d5 51d6 8c69 whose
exact value is +0.00830999999999999967859043437101718154735863208 770751953125
and 0.000001 is held as 3eb0 c6f7 a0b5 ed8d with exact value
+0.00000099999999999999995474811182588625868561393 8723690807819366455078125

If they are added, one gets 3f81 055b 8993 9218 with exact value
+0.00831099999999999894395585897655109874904155731 201171875 .

Only when that hex value is converted to String does one get
"0.008310999999999999" .

FAQ 4.7 <URL:http://www.merlyn.demon.co.uk/js-maths.htmand
<URL:http://www.merlyn.demon.co.uk/js-misc1.htmrefer; FAQ 4.6 may
help; see their references too.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 24 '07 #23
In comp.lang.javascript message <ZN********************@telcove.net>,
Mon, 23 Jul 2007 23:17:09, Randy Webb <Hi************@aol.composted:
>
Besides, don't make promises you don't intend to keep.
And keep the ones that you do make.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 24 '07 #24
In comp.lang.javascript message <11**********************@n60g2000hse.go
oglegroups.com>, Mon, 23 Jul 2007 17:08:50, David Mark
<dm***********@gmail.composted:
>On Jul 23, 7:35 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>You wanted more clear, you got it.

I didn't want anything. The OP wanted an answer and got it and
followed up to say it worked. Now you have made a real mess of
things.
Please don't argue with Randy. He has something more important to do,
and should be given no excuse for not doing it.

Randy's responses seen here so far will do little to aid the development
in the OP of a real understanding of the situation; an answer that is
dumbed down is a disservice to those who read it.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 24 '07 #25

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: George Hester | last post by:
At the time this suggestion was made I didn't have the wherewithall to even attempt it. But over time I learned enough to make a stab at it. Let just say the foating DIV had to provide the same...
3
by: DraguVaso | last post by:
Hi, When you double click on a form in the Solution Explorer, it will show that form in the Designe Mode. Is there a way to change this, so it will switcvh to the 'Code Mode'? Is this...
12
by: meltedown | last post by:
I would like the floating divs to float and then the header to come after them , on the left. That's what I thought clearing the floats was for, but in this example, the header is to the right of...
1
by: buliwyf_23 | last post by:
I have this: CSize sz; sz.cx = dwOutX1; sz.cy = dwOutY1; CPoint pt(sz); ClientToScreen(&pt);
6
by: Usenet | last post by:
I might be being silly here. On my links page I've got a whole load of floating boxes, which I'm really pleased with. But then I want the footer to be *below* them. On my current site...
2
by: Qiang | last post by:
Those who have used Google notebook may notice that google notebook displays the notes in a small floating window of the browser. I have tried to create a similar floating window, but with no luck....
3
by: mscertified | last post by:
My solution explorer window used to be over to the right of my screen. I have no idea how it happened but now it is a free floating window with no minimize button. I have to drag it out of sight to...
0
by: gdrenfrew | last post by:
I'd like to know if it is possible to stop the parent application of a floating form becoming active when the controls on the floating form are clicked? I've got a large application, with multiple...
2
by: murali.desikan | last post by:
Hi, The definition of floating literal in the C++ (ISO/IEC 14882:2003) grammar is as follows (Note: I have replaced the "opt" subscript used in the standard with to indicate optional symbol)....
6
by: Jeremy | last post by:
I've got a floating div which becomes visible when a link is clicked. I want the div to be hidden when the user clicks anywhere on the page except for whithin the div. What is the best way to do...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.