Questions tagged [ceil]

A function common to many programming languages that returns the next integer value by rounding the value up if necessary.

Returns the next highest integer value by rounding up value if necessary. php.net

Examples

echo ceil(1.3);    // returns   2
echo ceil(10.9);   // returns  11
echo ceil(-3.14);  // returns  -3
301 questions
2
votes
3 answers

get ceil value of number when divided in struts tag

I am using struts iterator for displaying my array list I had to put a condition in the end attribute of the iterator tag. how to get the CEIL value when two integers are divided. if array list size is 3 then I need to get output as 2 for end…
Vijay Rahul
  • 103
  • 1
  • 2
  • 11
2
votes
1 answer

Ceiling and integer +1 option in R software

Is there an elegant way to take either the ceiling (if the input is not an integer) or one integer larger (if the input is an integer) for each index of a vector? Such that, for example, vector x x = c(0, 4, 5.3333, 6.25) becomes vector y 1, 5, 6,…
user1830307
2
votes
1 answer

DecimalFormat not ceiling properly

We are currently running some tests which involve ceiling numbers that have two decimal places. In order to achieve this, we are using Java's DecimalFormat. However, the tests are getting strange results, particularly for the case when we wish to…
Goaler444
  • 2,591
  • 6
  • 35
  • 53
2
votes
2 answers

round to inferior odd or even integer in C

Working in C language, I would like to round a float number to its inferior odd integer and its inferior even integer. The speed of the solution is very important (because it is computed 2M*20 times per seconds). I propose this solution : x_even =…
Jav
  • 1,445
  • 1
  • 18
  • 47
2
votes
3 answers

Strange ceiling error in c++

Hello I have some difficulties with the ceil function in c++ : I've got a regular grid of points, and I need to perform an interpolation over it to compute the z-values of a set of points. In order to do that, I need, for each computed point, to…
2
votes
2 answers

Why Math.Ceil give unexpected result when the parameter is calculated variable value?

In the following code, the last two calls to Ceil give unexpected result. Could you help to comment on the reason? Furthermore, if the error (or deviation) is random, could I get the expected value? Ceil(Calculated_Var_Value) = 7 when…
SOUser
  • 3,802
  • 5
  • 33
  • 63
2
votes
1 answer

Excel: Alternative to CEILING for rounding to nearest value

Normally I ask about work stuff so here's something different. To approach my new year's resolution in the nerdiest way possible, I'm creating a gym program in an excel file. I'll be doing ramped sets, which means each set I increase the weight be…
Swiftslide
  • 1,307
  • 7
  • 23
  • 34
2
votes
1 answer

Round to the nearest dollar

I am looking for a way to round to the nearest dollar with the following stipulations: (If wholenumber.50 and above round up to the next whole number) (If wholenumber.49 and below round down to the current whole number) I have tried:…
Baxter
  • 5,633
  • 24
  • 69
  • 105
1
vote
2 answers

Java: BigInteger floor and ceil functions

I'm trying to implement an RSA attack in Java and I need to compute math operations like floor and ceil to BigInteger variables. As we know math.ceil and math.floor only apply to double variables, do you know any other way I can compute floor and…
1
vote
3 answers

PHP round & ceiling not correctly parsing data

The numbers that are being pulled from an xml file and then assigned to a variable but are outputted incorrectly. I'm not quite sure why or how to get around it. An example is this. $pricing_high = 1.15; echo $pricing_high; This displays 1.15…
Justin Lucas
  • 319
  • 2
  • 18
1
vote
1 answer

Where to find the source code of math function ceil() in glibc?

I have downloaded glibc's source code, and find the function ceil() for a long time, but I cannot find it, who can tell me where is it? And where can I find some detailed information about how to find certain function's source code in glibc's…
Yishu Fang
  • 9,448
  • 21
  • 65
  • 102
1
vote
3 answers

Code in PHP for the ceiling function

Anyone has ever programmed a PHP (or Perl) function to get the ceiling value Excel style?
Roberto Andrade Fonseca
1
vote
2 answers

Using ceil to get index of a PHP array

I'm trying to simplify some inherited PHP code that assigns a value to one variable based on the value in another variable, roughly mapping like this: if x < 50, y = 10 else if x >= 50 and < 100, y = 20 else if x >= 100 and < 350, y = 30 else y =…
joshuahedlund
  • 1,722
  • 2
  • 20
  • 25
1
vote
1 answer

Math.ceil ; Math.random

Here's a very basic issue that i cannot resolve on my mind: In JS if i do: Math.random() i will get random numbers between 0 and 1 (including 0, not including 1) So, if i do Math.ceil(Math.random() * 100) i will get random numbers between 0 and 100.…
lezammm
  • 23
  • 2
1
vote
1 answer

How to implement a floor function that rounds according to integers in a specified array?

I would like to implement a function very similar to the floor function, but instead of rounding towards the nearest integer, I would like it to round any number(s) according to a specified array, and I would like to code this in Matlab. For…
Yash
  • 21
  • 2