473,320 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ceil ceils what should be an integer

I have a simple calculation, which results in 110, but when i use ceil on the result i get 111, is there something hidden in the result variable?

code:

$result = 66/(100-40)*100;
echo "Result: $result | with Ceil: ". ceil($result);

update: i found a solution here: http://stackoverflow.com/questions/7...ith-no-decimal

$result = round($result,2); // does the trick
Nov 28 '11 #1
1 1594
omerbutt
638 512MB
hi ,
you need to look at the floval() and intval() function also if you are dealing with decimal calculations to preserve the decimal places when adding or subtracting , specially when dealing with shopping carts and other price calculation based work
regards,
Omer Aslam
Nov 28 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: RobG | last post by:
I am writing a script to move an absolutely positioned element on a page by a factor using style.top & style.left. The amount to move by is always some fraction, so I was tossing up between...
17
by: henrytcy | last post by:
Hi, How can I get a digit from integer for example, 12311, one by one for comparision? Thanks!
20
by: mikael.liljeroth | last post by:
Why do I get NO as result from this ?? double du = (double)3.1415; du = ceil(du); if(du == (double)4) printf("YES\n"); else printf("NO\n");
11
by: ChrisM | last post by:
Hi Guys, I'm looking for a function that will return the lowest integer that is greater than or equal to a decimal number. eg. 3.1(decimal) returns 4(integer) 3.9(decimal) returns...
18
by: Alex Vinokur | last post by:
Ho to get valid value of integer part of double _as int value_? Here is a program that demonstrate the problem. ------ foo.c ------ #include <stdio.h> #include <math.h> int main () {
9
by: jm.suresh | last post by:
Hello all, I have two integers and I want to divide one by another, and want to get an integer result which is the higher side whenever the result is a fraction. 3/2 =1 # Usual behavior...
12
by: Godzilla | last post by:
Hello, I'm trying to find a way to convert an integer (8-bits long for starters) and converting them to a list, e.g.: num = 255 numList = with the first element of the list being the...
15
by: Alasdair | last post by:
I need to apply the ceiling function to arbitrary sized (long) integers. However, division automatically returns the type of its operands, so that, for example: math.ceil(7/4) returns 1. I can use...
7
by: MrIncognito | last post by:
Am I using this correctly? This line of code is supposed to find the number of bytes in one line of a 16 color bitmap, but it doesn't seem to work most of the time. long linesize = ceil((double)...
7
by: mingke | last post by:
I've learned that we can round up and down a float number by using Ceil and floor function. But, is this function still able to work if I the number I want to round up (or down) is zero? I have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.