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

  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts

    Decimal

    How could I change a number to a decimal, like 4 to .04 like percents.

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,394
    Thanks
    13
    Thanked 353 Times in 349 Posts
    I don’t get what you mean by decimal. and what kind of conversion?
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    If you are asking of changing 4 to .04 like percents, you simply divide it by 100 ...
    PHP Code:
    $p $p/100
    If the question is different, could you explain it a little bit more in detail please ?

  • #4
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    Lol, ya thats what it is, and im good at math, but whenever it comes to this I want to make sure im doing it right.

    PHP Code:
    $buildtimediv[$num] = (1*962)*((2*2)/100); //To get 4% of 962(16:02)
    $buildtime[$num] = (1*962)-$buildtimediv[$num]; //Subtract the 4& from orig. 

    Would that be correct? and how do I convert the outcome back to a time.

    The 1* part is acually an output from a form based on how many you want to build
    and
    The 4* is based on your level and *2 because the % is x2 your level and thats the part I need help turning into a decimal which the /100 does.
    Last edited by Ndogg; 02-26-2010 at 10:14 PM.


  •  

    Posting Permissions

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