Welcome to WebmasterWorld Guest from 54.167.58.159

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Newbie trying to learn

     

I Will Make It

10:17 pm on Feb 27, 2014 (gmt 0)

5+ Year Member



Hi!

I'm trying to learn some easy php.

Right now I would like to understand how I can take a number, ex: 42.5 and round it up or down to the closest number that ends on 9.

As in: 42.5 would be 39
but 47 would be 49

lucy24

10:44 pm on Feb 27, 2014 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Which direction do you want 44 to go?

:: thinking ::

Add 1, divide by 10, round to an integer.

I Will Make It

10:48 pm on Feb 27, 2014 (gmt 0)

5+ Year Member



I didn't think of that scenario ;) But up :)
I'm making a small code that takes the cost price from my supplier, and converts into the saleprice on my webshop :)

Thank you for your quick response!

LifeinAsia

12:16 am on Feb 28, 2014 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



add 1, divide by 10, round to an integer, multiply by 10, subtract 1. :)

lucy24

3:00 am on Feb 28, 2014 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



"Having reduced the problem to a previously solved one, the mathematician went back to sleep."
:)

I Will Make It

6:28 pm on Feb 28, 2014 (gmt 0)

5+ Year Member



I fixed it :) Thanks all