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
1
vote
1 answer

ceiling time_point to runtime defined duration

I'm ceiling time_point to next full five minutes, which is quite easy: template using minutes = std::chrono::duration, std::chrono::minutes::period>>; const auto now =…
oley
  • 21
  • 1
1
vote
3 answers

Ceil only floating point numbers in bash linux

In linux bash, I want to get the next integer for a given number only if it is a floating point number. I tried with count=$((${count%.*} + 1)); But with the above code, all the time (even if the number is not floating point), it is giving next…
Jenz
  • 8,280
  • 7
  • 44
  • 77
1
vote
1 answer

TypeError numpy dtype int

Hello i have a verry simple problem. but i don't understand what cause the problem. I have the following python(3) script. i have numpy 1.13.1(an old one but my problem with dtype should work). according to this the dtype exist in ufunc since…
Jan-Bert
  • 921
  • 4
  • 13
  • 22
1
vote
2 answers

Using $ceil to define a parameter in SystemVerilog in Quartus Prime

Trying to do this parameter integer PRECHARGE_CLOCKS = $ceil(PRECHARGE_NS / CLOCK_PERIOD_NS); And then use the value in a comparion if(InitPrechargeCounter < PRECHARGE_CLOCKS - 1) But getting this error Error (10174): Verilog HDL Unsupported…
axk
  • 5,316
  • 12
  • 58
  • 96
1
vote
2 answers

How do I round a decimal result up in Thymeleaf (same behavior as Math.ceil)?

I am doing table pagination logic for my project using Thymeleaf. I have two values: int totalRows int rowsPerPage The operation I want to do is something along the lines of Math.ceil((1.0 + totalRows) / rowsPerPage) to store in a variable that…
1
vote
1 answer

Floor and Ceil of Binary Search Tree Python

I am trying to work out the ceil and floor values of a bst, the ceil code works but I cannot get the correct value for the floor, I compute the floor of 10, which in the test case provided should be 10, but it returns 9 and I am not sure why. Any…
1
vote
1 answer

Rounding integer in php to nearest upper integer

I have the integer $price = 19.999999995; I want the php to print out any integers similar to $price integer to upper integer value which is "20". $total = ceil($price); I am expecting the above $total value to be 20 , but it's return "21". How…
Q8root
  • 1,243
  • 3
  • 25
  • 48
1
vote
2 answers

why math.ceil return a integer in flask shell command?

ENV: python: 2.7.5 flask = 0.12.2 flask-cors = 2.0.1 flask-script = 2.0.5 start a python shell: $ python Python 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2 Type "help", "copyright", "credits" or…
pangpang
  • 8,581
  • 11
  • 60
  • 96
1
vote
3 answers

.NET: Can you simplify this Math.Ceiling expression

Can you simplify this Math.Ceiling expression decimal total decimal? quantity, multiplier int? days total = (decimal)Math.Ceiling((double)quantity.Value * (double)days.Value * (double)multiplier); EDIT I forgot to mention that this is Silverlight…
Jonathan Allen
  • 68,373
  • 70
  • 259
  • 447
1
vote
1 answer

Can python's math.ceil function get tricked from floating point representation error?

The question is in the title, for example what I am worried about is: If I calculate math.ceil(math.log(4,2)), do I have the risk of getting 3 instead of 2 because the log will return 2.0000000000000343 instead of 2.0? I suspect not but I haven't…
EugVal
  • 233
  • 1
  • 14
1
vote
0 answers

Handling ceiling effect of dependent variable in mixed models (R lmer)

I would like to ask around who has any experience with handling ceiling effects of the dependent variable in linear mixed effects models. I found this paper here suggesting results for models outside mixed modeling (…
1
vote
2 answers

math.ceil(0.5) returning different value from math.ceil(1/2)

import math print(math.ceil(0.5)) Returns 1.0 But import math print(math.ceil(1/2)) Returns 0.0 What's going on here? Explanation would be nice.
Oscar Johansson
  • 135
  • 1
  • 2
  • 11
1
vote
2 answers

Ceiling double two digits after point

I have two numbers, for example: 1.51 and 1.56 I need to have: 1.55 and 1.60 but, if it is 1.55 it just stay as 1.55.
Vaso Beruashvili
  • 678
  • 2
  • 7
  • 14
1
vote
2 answers

Round off to whole number

The program is about getting the average of all laboratory exercise. I want to round off my decimals 7.7778 to the whole number. I tried the ceilf and roundf() its not working, is there any problem with my codes? any help will be appreciate thank…
Holow
  • 31
  • 1
  • 7
1
vote
2 answers

Ceiling of Long Integer division in c++

I was trying to solve some problem which involves division of large numbers. I stumbled upon certain scenario where I'm getting wrong results using: LL result = (LL)ceil((double)(a-b)/c), where a,b and c are long long integers(LL). #include…
gautamk
  • 15
  • 1
  • 3