To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.publishOpen lugnet.publish in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Publishing / 209
208  |  210
Subject: 
Re: Soliciting comments (and help) with online form
Newsgroups: 
lugnet.publish
Date: 
Mon, 14 Dec 1998 17:23:39 GMT
Reply-To: 
lpien@STOPSPAMctp.iwantnospam.com
Viewed: 
663 times
  
Mike Stanley wrote:

Ok, been playing with a javascript form today and I think it's fairly
nifty.  No super-duper backend database or anything, but it does
fulfill a couple of the requests I've had so far for making selecting
quantities and items easier.

Here's the address of the form:

http://www.guarded-inn.com/lego/auction/test3.htm

Now, one thing I have noticed, and I don't quite understand it, is
this situation.  When I select this item:

Black 1x1 Shallow Cooking Pans w/Handle

And a quantity of 3, 7, 17, and some other higher odd numbers, but not
all of them, the math it does is wrong.  3 x .35 becomes 1.04, 7 x
.35 becomes 2.44, etc.  Any ideas why that is?  Or does it work for
other people?

Roundoff error? Do your math in pennies and divide by 100 at the last
minute.

This is a known problem in some languages. Since decimal fractions are
repeating binimals when represented in binary (that is .3 is not a
closed form sum of any combination of powers of two) sometimes roundoff
error creeps in. That is, .35 is not really .35, it is .1010101110 (or
whatever) binary, and if the language does not take it into account, you
get round off error.

I dunno about Javascript's math capabilities. I do know that in C++ and
Java, we usually use a package that does decimal math (for instance,
Money.h++ from Rogue Wave) to get round (1) the problem.

1 - ouch
--
Larry Pieniazek    http://my.voyager.net/lar
For me: No voyager e-mail please. All snail-mail to Ada, please.
- Posting Binaries to RTL causes flamage... Don't do it, please.
- Stick to the facts when posting about others, please.
- This is a family newsgroup, thanks.



Message has 1 Reply:
  Re: Soliciting comments (and help) with online form
 
(...) *sigh* I can just hear my trig teacher laughing at me now since I must have told her a million times, "but Ms. Smith, who cares about math? I'm going to major in Latin and teach high school - I'll never need to do anything with numbers besides (...) (26 years ago, 14-Dec-98, to lugnet.publish)

Message is in Reply To:
  Soliciting comments (and help) with online form
 
Ok, been playing with a javascript form today and I think it's fairly nifty. No super-duper backend database or anything, but it does fulfill a couple of the requests I've had so far for making selecting quantities and items easier. Here's the (...) (26 years ago, 14-Dec-98, to lugnet.publish)

10 Messages in This Thread:




Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR