309 questions
0
votes
2
answers
114
views
Efficiently Count Number of Ones at Deepest Level in Recursive Floor-Ceil Splitting of Large Binary Number
I have a number represented as a large binary string (length can be up to 1 million bits). The number is recursively split as follows:
At each step, divide the number
x into two parts:
floor(x/2) and ...
0
votes
0
answers
43
views
Error: [BC30516] Overload resolution failed because no accessible 'Ceiling' accepts this number of arguments
I'm trying to use the ceiling function in report builder power bi but it gives error each time I run the report.. and I get below error:
The 'Value' expression for the field 'Sheet1_Budget2' contains ...
1
vote
0
answers
104
views
Why does using any in-built functions not rounding a 0.5 decimal to 1? [duplicate]
I need to round off each decimal values to its nearest whole number, anything less than 0.4 to be rounded off to 0, and 0.5 and above to be rounded off to 1.
But when i try that in C++ no matter which ...
0
votes
1
answer
60
views
Why the height of segment tree is O(logn)
I don't get why the height of a segment tree is O(logn).
https://dzone.com/articles/binary-trees-part-1
Based on the article above, the maximum height of a full binary tree with n nodes is (n-1)/2 (-&...
0
votes
1
answer
166
views
ceil(double(int)*double) or ceil(float(int*double))?
I had this C++ code:
int x;
double y;
// do sth
int z = ceil(x*y);
If x = 410, y = 1.1, then z = 452 when it should've been 451. I changed to z = ceil(float(x*y)) and it works. My friend suggests z ...
0
votes
1
answer
90
views
Ceiling and Floor of a number for array in descending order (Java)
This is the program I wrote to find ceiling and floor of a Number.
public class BinarySearchAlgorithm {
public static void main(String[] args) {
int[] arr = {10, 9, 8, 7, 4, 3, 2, 1};
...
1
vote
1
answer
87
views
How can I move datetime to the closest five minutes?
I am working with a dataframe in pandas. In this dataframe there is a column which type is datetime. It represents the moment in which a product is sold, other columns indicate the price, the type, ...
2
votes
1
answer
298
views
How do I get ceil to work when variable on left of '=' is an int, and variable on right is a double?
EDIT: To rephrase this question, how do I avoid truncation when assigning a double value to an int variable that displays and rounds up said value using ceil? Without changing their declaration, if ...
-1
votes
1
answer
72
views
How to select from a vector of fractions and respect the number of elements? [duplicate]
I have a vector of fractions a = [0.04352034965262487, 0.480655360084497, 0.02655889003246612, 0.449265400230412, 0.0] of type float64 such that of course sum(a)=1. These fractions represent ...
0
votes
1
answer
168
views
I am unable to use a variable inside of the ceil function even after including the math header file [duplicate]
I am trying to find the the ceil of a variable which was been assigned a value but when I pass the function ceil("variable name") it throws an error.
#include <stdio.h>
#include <...
1
vote
1
answer
355
views
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() * ...
-1
votes
1
answer
72
views
Printing answer directly using cout gives wrong answer, whereas storing the answer and then printing using cout get accepted [closed]
I am solving problem 1A : Theatre Square(https://codeforces.com/problemset/problem/1/A) on Codeforces.
Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters....
1
vote
1
answer
355
views
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 ...
0
votes
1
answer
103
views
CEILING fnc in Excel in Javascript?
CEILING in Excel =CEILING(E2,6)/60 for calculating legal billable hours in 6 min increments from minutes (1 min = 0.1, 5 min = 0.1, 7 min = 0.2 etc) when transposed to JS with the CEIL function as:
...
1
vote
2
answers
362
views
How can I plot a discontinuous ceiling function?
Here is the code I am using to plot graph of ceiling function in python.
import math
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-5, 5, 0.01)
y = np.ceil(x)
plt.plot(x,y)
plt....
2
votes
2
answers
143
views
Customized floor/ceiling for dates in R
say I have a date range from start to end where start <- as.Date(2009-11-05), end <- as.Date(2009-12-17).
I want a function that essentially acts as a customized floor/ceiling and returns a date ...
0
votes
0
answers
75
views
PHP ceil calculation differs in result from manually calculated result
I have this script:
function round_price_with_limits( $price = null, $multiplier = 9.3, $nearest = 10, $minus = 0.05, $map = 9.95, $msrp = 9999999999) {
// Ensure a price was provided.
if ( !...
0
votes
0
answers
23
views
how to overload std::ceil() in my program [duplicate]
I use my own data type in Eigen lib by template,and I realize +-*/ overload , but Eigen use std::ceil() function, I don't know how to overload this.
thanks for every suggestion.
just tell me How to ...
2
votes
2
answers
715
views
How ceil function works in c++?
When I execute this code the value of ans1, ans2 is 50002896 and 50005000.
I know there is some issues with ceil function but was not able to figure out the exact cause.
#include <bits/stdc++.h>
...
-2
votes
1
answer
178
views
Ceil any number in python this way - 2.3, 2.1, 1.9, 2.6. to 2.5, 2.5, 2, 3 i.e. addition leads to addition of .5 or 1 whichever is closest [duplicate]
Default ceiling doesn't work this way.
Ceil should work in this way -
Example 2 -
3.1, 4.5, 5.9
after ceiling - 3.5, 4.5, 6
0
votes
0
answers
57
views
I want to round line items of orders and then sum the aggregate of the rounded values. Is it possible to round line items UP and then SUM them?
Essentially the query works like this:
Select Sum(Ceiling((Exp_Cart)*Exp_Qty) from Table_X where Item in ('3')
I am receiving an error in my query and wondering if there is a better way to approach ...
-3
votes
1
answer
488
views
How to pass an expression as input and it gives the ceil value as the output? [duplicate]
a. In variables a,b gets the input from the user so as to evaluate the expression from the given input and it gives the ceil and floor values as the output.
def ceil_flooor():
a = float(input())
...
1
vote
2
answers
609
views
JavaScript BigInt ceil() function
Given that Math.ceil(1/3) yields 1, how do I get that 1 (or 1n) from BigInt input values of 1n and 3n?
Obviously Math.ceil(Number(1n)/Number(3n)) would work but some bigints might be too big for that ...
-1
votes
1
answer
314
views
Math.ceil for positive value greater than zero? [duplicate]
The following code is giving me a wrong answer and I can't understand why.
int x = 10;
int y = 15;
System.out.println((int)Math.ceil(x/y));
Result:
0
I was expecting a 1 as the answer.
0
votes
2
answers
224
views
Python Cplex Ceil() Function
ceil() in the constraint
Hello, I am studying a published paper. One of the constraints from this paper(which can be shown in the link) requires the ceil() function. We can use the ceil() function at ...
0
votes
2
answers
647
views
how to perform oracle ceil with decimal points
In round function we can use (4,512,1) but the same is not true for ceil and floor. I want to ceil and my floor the value 4,512 as 4,5 and 4,6 but the decimal point 1 is not always constant. it may ...
1
vote
1
answer
173
views
Why does NVCC not optimize away ceilf() for literals?
(Followup question for Compile-time ceiling function, for literals, in C?)
Considering the following CUDA function:
__device__ int foo_f() { return ceilf(1007.1111); }
It should be easy to optimize ...
2
votes
2
answers
631
views
Compile-time ceiling function, for literals, in C?
I have a C program which involves some floating-point literal that's defined by a macro. And - it just so happens that in a performance-critical part of the code, I need the ceiling of that floating-...
0
votes
1
answer
311
views
is it possible to round the last 3 digits of a number in c?
i would like to round the last 3 digits of the float number 169786.122 and leaving only 3 digits
is it possible to do it with the math.h library and the ceil function?
in case of 169786.122 == 170
in ...
0
votes
0
answers
25
views
Storing ceil( divison ) in an integer in c++ [duplicate]
Sorry for the maybe stupid question. I wanted to write a straightforward c++ code that takes the number of people and returns how many baking trays of 12 muffins I have to bake when everyone gets two ...
3
votes
1
answer
1k
views
Rounding up a number to two decimal places in c++
I'm wishing to round up a float variable to two decimal places regardless of what the float is. My current code is shown below:
void MainMethods::convert(float& floatValue, string numericString)
{...
0
votes
2
answers
2k
views
Oracle : how to subtract two dates and get seconds of the result
I have created oracle NVL function which would subtract start and end time column and give the result
However I am not getting correct output value
Example
Start time- 2:33:10
End time -2:33:20
...
1
vote
1
answer
133
views
Math Function to convert Digits in Android - Kotlin
I am hoping for below outcomes :
If Input => 25.69 - OutCome should be 25.6
If Input => -0.40 - OutCome should be -0.4
If Input => -0.004 - OutCome should be 0 or 0.0
To achive this I have ...
1
vote
1
answer
431
views
How can we achieve excel ceiling function with significance value in SQL Server
How can we apply excel ceiling function with significance value in SQL server ?
=Ceiling(10,3)
it should return 12, because 12 is roundup nearest to 3
=Ceiling(36,7)
it should return 42, because ...
2
votes
1
answer
474
views
Problem with ceil function in math module
by performing the following calculation
p=math.ceil(57050*1.12)
I am receiving 63897. However other tools (such as Excel) deliver 63896.
I need to use ceil (round up), because the procedure is part ...
0
votes
1
answer
113
views
Answer is coming different in Math.ceil() in java?
When I use 0.0 + in Math.ceil() method in below code, the answer with op=1 and cl=11 is 7 which is correct.
(int)(Math.ceil((0.0 + op) / 2) + Math.ceil((0.0 + cl) / 2))
But when I don't use 0.0 + ...
0
votes
1
answer
649
views
When rounding a decimal/float to an integer, what's the difference between using round, floor or ceil in python?
When trying to round a decimal point value (a float) to an integer, what is the actual difference between the round, math.floor and math.ceil functions in python?
0
votes
1
answer
444
views
python round numbers to specific value [duplicate]
I would like to write a specif rounding logic.
number = x
if x < 950:
# round number to and in steps of 50
elif x < 9000:
# round number to and in steps of 100
elif x < 100000:
# ...
0
votes
1
answer
559
views
Oracle difference between to dates in days without considering time
How to get days count from CURRENT_TIMESTAMP without considering time (hours,minutes,seconds).
for eg. CURRENT_TIMESTAMP is 24-JUN-21 00.01.01 AM
and EVENT_TIMESTAMP is 23-JUN-21 07.00.00 PM then it ...
0
votes
1
answer
59
views
Round the values with weightage of numbers in python with upper and lower values
I have a number and i need to get the closest 1000th value. Both upper side and lower side along with the difference between numbers so that i can give weightage.
Example:
Number_1 = 25460
Expected ...
0
votes
1
answer
152
views
Ceiling function apparently rounds incorrectly [duplicate]
Could someone please explain why R has a problem with rounding/ceiling and how you can make sure that it calculates correctly?
N = 50e3
x = vector(length = N)
p = 0.995
ceiling(length(x)*(1-p))
251
...
2
votes
1
answer
371
views
If Perl already links to libm, why aren't any of the functions exposed to the user?
Perl already links to libm.
$ ldd $(which perl)
...
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd8ce2ea000)
...
So if Perl already links to libm, why aren't often used ...
0
votes
1
answer
250
views
sql sum round up
Sql newbie here, Im stuck on a problem.
I have a recipe ingredient table, and basically what I want to do is find the price of a recipe rounded up to whole ingredients.
So I wrote this sql.
select ...
8
votes
1
answer
3k
views
Julia: Can ceil/floor return an integer?
Why don't ceil() and floor() return an integer? How can I return an integer?
a = 10
b = 3
typeof(a/b)
## Float64
c = ceil(a/b)
typeof(c)
## Float64
This issue bothered me in the context of ...
0
votes
1
answer
613
views
Assistance finding the floor and ceiling of a vector
I have created vectors for months and month numbers, then for months 6-9, and from there, the mean...
mean(Summer)
Months[mean(Summmer)]
July
Now I have to use floor and ceiling functions to return ...
-1
votes
2
answers
41
views
diffrent return value for same arguement of ceil() function
#include<bits/stdc++.h>
using namespace std;
int main() {
int ans = ceil(1.5);
printf("%d\n", ans);
ans = ceil(3 / 2);
printf("%d", ans);
}
Output:
2
1
...
0
votes
1
answer
455
views
Rounding up values using np.ceil
Why does np.ceil give me different answers for what should equivalent expressions?
np.ceil(336)
Out[34]: 336.0
np.ceil(100*(2.85+0.43+.08))
Out[35]: 337.0
2
votes
3
answers
723
views
Round to the next tens in Python
Is there a way to round always up to the next tens? E.g., 0.000000000003 shall become 0.1. 0.1244593249234 shall become 0.2 and 0.9x shall become 1. Negative numbers are not a thing here.
Is there a ...
0
votes
0
answers
32
views
How i can round this number 5.53 always like this: 5.55 in PHP? [duplicate]
I want to round number 5.53 always like this: 5.55 in PHP ?
Any idea?
1
vote
1
answer
998
views
JTable how to remove header border
Example:
I have problem with table header. How can i remove this white border or change color of it?
My code:
JTableHeader header = table.getTableHeader();
header.setBackground(new Color(21, 25, ...