Rounding Numbers
Thursday June 15, 2006
PHP allows for more than one way to round a number. If you are just doing a traditional round, where anything at or over .5 is rounded up and anything below .5 is rounded down, you would use the round () function.
Sometimes when you're working in whole numbers, you need to round everything up.... for example if you wanted 10 photos per page, and had 52 photos, you could not make 5.2 pages, you would need 6 pages. You can round everything up using the ceil () function. Likewise, you can also round everything down using the floor () function.
Sometimes when you're working in whole numbers, you need to round everything up.... for example if you wanted 10 photos per page, and had 52 photos, you could not make 5.2 pages, you would need 6 pages. You can round everything up using the ceil () function. Likewise, you can also round everything down using the floor () function.


No comments yet. Leave a Comment