Solved

Round DOWN to nearest 50000 ?

Posted on 2006-07-18
2
651 Views
Last Modified: 2013-12-12
Hi all

I need to be able to round down a number to the nearest 50000 ...any ideas on how to do this? Are there any existing php functions that can handle this? It's a bit beyond the round() functions isn't it?

Example 1:
$input = 35001;
$output needs to be 350000;

Example 2:
$input = 34999;
$output needs to be 300000;

Cheers,
Mark
0
Comment
Question by:msiedle
2 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17135501
If you are rounding down - you can just subtract the remainder from a modular division

ie
$roundFigure = 5000;
$input = 35001;

$output = $input - fmod ($input, $roundFigure;

Which should give

35000
0
 
LVL 2

Author Comment

by:msiedle
ID: 17135554
Beautiful! Thank you :-)

M
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now