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
2 answers

Division Round Up in C++

How can I round up when performing division on two int values in C++ without using std::ceil? Typically I end up doing something like the following: double res = ceil(a / (double) b); Is there any way I can duplicate the result without using…
coder_jam
  • 94
  • 12
2
votes
3 answers

Why combining pipeline operator with ceiling function doesn't work in R?

When I try to use ceiling() function, it works okay, but when I try to divide something and give it to the ceiling function using pipeline operator (2/10 %>% ceiling()), I get a problem. ceiling(0.2) 1 ceiling(2/10) 1 2/10 0.2 2/10 %>%…
Mehdi Abbassi
  • 627
  • 1
  • 7
  • 24
2
votes
1 answer

Liquid not rounding up on ceil

I am trying to get Liquid to simply round up a number. Here is my code: {% assign loopCount = page.boxCount | plus:0 | divided_by:3 | %} {{ loopCount | ceil }} In this case loopCount = 4. I can confirm it is a number by adding to it and…
PruitIgoe
  • 6,166
  • 16
  • 70
  • 137
2
votes
1 answer

Slowness of numpy.ceil and numpy.clip in ReLU thresholding: where is the bottleneck?

This is a question based on (or follow-up of) another question: Faster implementation of ReLU derivative. In a spirit to come up with a fastest way of computing the derivative, I wrote some solutions of which one is: In [35]: np.random.seed(0) …
kmario23
  • 57,311
  • 13
  • 161
  • 150
2
votes
1 answer

Lua math ceil round up number when there is no digits after decimal point

I would like to round up the numbers by using math.ceil in Lua. Some of the cases are make sense like: ceil(260.5) -> 261 But some of the cases are weird like: ceil(2.2*100) -> 221 # Suppose there is no round up and the answer is 220 I have no…
appletabo
  • 239
  • 2
  • 12
2
votes
1 answer

Bound my result to [-1,1] in SAS

I am calculating a fraction based on the payments made in four years and I wish to put a cap on my fraction such that it can only be between -1 and 1. Subsequently I'd like to make the following fractions 0 if the cap is maxxed out - an example…
78282219
  • 593
  • 5
  • 21
2
votes
5 answers

How do I randomly generate a number between 75 - 100%?

I know how to do it between 0 and 100, but I can I set the floor? This is how I do 0 - 100.. int randomNum = (int) Math.ceil(Math.random() * 100);
Sapp
  • 1,793
  • 7
  • 29
  • 51
2
votes
3 answers

how to find nearest equal or higher multiple of ten in python

I have a this small task , where I am rounding up the number to higher multiple of ten. But want to round it to nearest multiple of ten. My code : import math a = map(int,list(str(7990442))) b = map(int,list(str(1313131))) print "a :",a print "b…
Shivkumar kondi
  • 6,458
  • 9
  • 31
  • 58
2
votes
0 answers

PHP - round() function with PHP_ROUND_HALF_DOWN mode (unexpected behavoir)

Currently I am working with PHP 5.3.29 and the round() function in PHP_ROUND_HALF_DOWN mode to round a specific number. Here is my code: function getBetragrabatt($betrag, $rabatt, $ratezahl = false){ if(!empty($rabatt)){ $rabatt =…
Codehan25
  • 2,704
  • 10
  • 47
  • 94
2
votes
5 answers

Python division operator gives different results

In Python I am trying to divide an integer by half and I came across two different results based on the sign of the number. Example: 5/2 gives 2 and -5/2 gives -3 How to get -2 when I divide -5/2 ?
Sriram
  • 999
  • 2
  • 12
  • 29
2
votes
1 answer

SQL group by steps

I'm using SQL in SAS. I'm doing a SQL query with a GROUP BY clause on a continuous variable (made discrete), and I'd like it to aggregate more. I'm not sure this is clear, so here is an example. Here is my query : SELECT CEIL(travel_time) AS…
François M.
  • 4,027
  • 11
  • 30
  • 81
2
votes
1 answer

Excel to SQL - CEILING and Error code 1582

I have the following excel formula: CEILING(F9*6763.85873627538/((F9-1)*400+6763.85873627538),1) Where F9 is named PROJECTED_QUANTITY in my table sample_size_by_service_id I have the following SQL query written out: select PROJECTED_QUANTITY,…
sqlnewb
  • 121
  • 1
  • 11
2
votes
1 answer

Anything like Mathf.Ceil which understands magnitude of a number whether +/-?

I need to round to the next biggest magnitude. So 6.66 rounds to 7, but -6.66 rounds to -7. At the moment I'm doing: int result = Math.Ceil(num); if(num < 0) result -= 1; I'm in the middle of a 2k*2k*2k nested loop, so saving an if/subtract…
Steve555
  • 173
  • 1
  • 7
2
votes
3 answers

What’s the Linq to SQL equivalent to CEILING?

How do I do this SELECT CEILING(COUNT(*) / 10) NumberOfPages FROM MyTable in Linq to SQL?
ACP
  • 34,682
  • 100
  • 231
  • 371
2
votes
4 answers

ceil function with high precision

How do I round up a number to the next integer with a high precision? Input: var1 = (8193/4096) # var1 = 2.00024414063 Output: 3 # As an integer >>> var1 = 8193/4096 >>> import math >>> math.ceil(var1) 2.0 >>> math.ceil(8193/4096) 2.0 >>> import…
0x0
  • 2,915
  • 5
  • 40
  • 67