# Stack Overflow

I called the functionceil(a/b). Naturally I would assume that the answer returns2but instead it returns1.

How to cancel a text that hasnt sent, before it does send?

Student caught cheating when leaving class after handing me the exam

a/bwill perform an integer division since they areintegraltypes, which will result in1, this explains whystd::ceilreturns the value you are seeing. if we look at thedraft C++ standardsection5.6Multiplicative operatorsparagraph4says(emphasis mine):

Both 63 and 32 are ints, hence the result will be an int (i.e. 1 and not 1.96875).

A topos where every object is internally projective but not every object is projective

How can I identify in advance if the air is going to be clear or not?

Is there lift of q-Vandermonde identity to some geomeric (motivic) identity for Grassmanians over F_q

If you expect to get 2, you need to convert to double before the division occurs, i.e.ceil(double(a) / double(b))uses double division.

How to tell my GF Im willing to listen her, but leaving her the option to say no?

Can a Martial Adept Superiority die be used on a melee/ranged spell attack?

How to decompose a self intersecting polygon into simple polygons?

How do I figure out which platform a SEPTA regional rail arrives at for a particular station?

Improving work conditions of student assistants, PhDs, Postdocs etc

How Can You Use In Medias Res To Beautify Your Amazing Masterpiece?

Is it more secure to program a client-server system in a language other than English?

Why cant I cd to a quoted tilde (~)?

Im puzzled. I have tried casting the variables to adoubleorintand it doesnt seem to help.

Otherwise, if either operand is double, the other shall be converted to double.

Lets break down what happens when you doceil(a/b). First, an integer division happens between a and b, so 63/62 becomes 1, and then 1 is casted to double to become 1.0, and then ceil(1.0) is of course just 1.0.

One of my stock positions has grown substantially. Should I rebalance my portfolio?

You technically only need to cast the first one, because then you will get floating-point division instead. But its good to be explicit and cast both.

Can white win in this almost 20 year old puzzle?

casting either of the operands todoublewill be sufficient due toarithmetic conversionswhich are covered in section5Expressionsparagraph10which says(emphasis mine):

Many binary operators that expect operands of arithmetic or enumeration type cause conversions and yield result types in a similar way. The purpose is to yield a common type, which is also the type of the result. This pattern iscalled the usual arithmetic conversions, which are defined as follows:

How do malware rely safely on ECDH algorithm to maintain secrecy of keys?

How to handle a developer getting defensive when faced with breaking code?

How to have good public opinion of police in a place with low or no crime?

Either typecast it as specified by paddy or

site design / logo 2018 Stack Exchange Inc; user contributions licensed undercc by-sa 3.0withattribution required.rev2018.5.4.30300

Start here for a quick overview of the site

Client not satisfied with the design. Doesnt want to pay

Stack Overflow for Teams is Now Available

Theceilandfloorfunctions work ondoubletypes. You have done an integer division (becausesize_tis an integer type), so the result is an integer (ieits already a whole number, so you cannot round up or down). Try casting todoublebefore the division:

Discuss the workings and policies of this site

Detailed answers to any questions you might have

So the following expression will yield the result you desire:

The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined.For integral operands the / operator yields the algebraic quotient with any fractional part discarded;[…]

How can Twitter and GitHub be sure that they havent been hacked?

Can I show the standard price on the product layout page?