Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder StadriWebmaster's Avatar
    Join Date
    Aug 2011
    Location
    NY
    Posts
    42
    Thanks
    4
    Thanked 2 Times in 2 Posts

    Price calculator and rounding

    I am currently using a price calculator - although it's really not a calculator; I have to enter every price manually. Currently, it works in half inch increments.

    I need it to do two things that it doesn't do currently:
    1) Allow the customer to enter a dimension in 1/4 inch increments (1/8 would be even better, but I'm not requesting a miracle)
    2) Make the result automatically round up to the nearest 1/2 inch

    Page containing calculator

    External file: sizecalc.js

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    How do you want them to *enter* the fractions?

    Do you want them to be 3 3/8 (depending on a space between the whole number and the fraction) or do you want to make the user enter 3.375?

    Clearly, making the user enter the size as a decimal fraction makes the whole exercise trivial. It's only the need to translate mixed fractions to decimal, do the calculations (?? which are what??) and then convert the decimal back to mixed fraction that's a lot of work.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    I don't understand this calculation:
    Code:
    size = (parseFloat($('patch_width').value) + parseFloat($('patch_length').value)) / 2;
    That's clearly not trying to calculate the *AREA* of the patch. Is it just some kind of arbitrary measurement used in your system?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •