homepage Welcome to WebmasterWorld Guest from 54.196.225.45
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Newbie trying to learn
I Will Make It




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

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




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

Which direction do you want 44 to go?

:: thinking ::

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

I Will Make It




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

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




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

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

lucy24




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

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

I Will Make It




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

I fixed it :) Thanks all

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved