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 4 of 4

Thread: decimal delima

  1. #1
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts

    decimal delima

    input = .2

    PHP Code:
    var check = (input/2) * .001
    check = .1


    this doesn't give me the proper answer cause if I have input = to .2 then the answer I get is .1 when it should be .0001
    any help?


    Jason

  • #2
    Regular Coder dswimboy's Avatar
    Join Date
    Nov 2003
    Location
    mostly in Ann Arbor
    Posts
    458
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    var input = .2;
    var check = (input/2) * .001;
    document.write(check);
    works dandy on my machine. are you sure you aren't modifying the variable anywhere else in the script?
    "There is more than one way to do it."

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know if it matters, but try changing .2 to 0.2 and likewise .001 to 0.001

    Sadiq.

  • #4
    Regular Coder dswimboy's Avatar
    Join Date
    Nov 2003
    Location
    mostly in Ann Arbor
    Posts
    458
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    var input = 0.2;
    var check = (input/2) * 0.001;
    document.write(check);
    still get .0001
    "There is more than one way to do it."


  •  

    Posting Permissions

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