When I truncate a number what my brain actually does is ignoring the fractional part of said number. But its not doing any real math.
I understand I can express a truncate function with conditional floor and cealing functions... but thats is not what I need.
I need someone to teach me how to arrive from a number to its integer using only mathematical operations and not logical functions.
I need to know...
Plz help me someone...
Videos
I recently found out about the floor and ceiling functions. Why would you want to round a number up or down to the nearest integer?
Hi all.
I’ve got several programmable AOS (Texas Instruments) and RPN (Hewlett Packard) calculators.
How would I write floor & ceiling functions for both AOS & RPN calcs?
Soooo, I am very green/new to any type of code and programming. I understand the base concept of the floor/ceil. Functions but unsure how to incorporate them to my current code. I can give brief details of deliverables. Prompt user to input 2 values to be converted from Celsius to Fahrenheit. Determine which of the 2 is the "start/stop" values. Once start and stop are determine, the program converts every value in the range input from user to Fahrenheit, in 1 degree increments.
I have all of the code complete.. my issue is floor and ceil functions just won't round up or down as expected. Not proficient enough to determine where my code needs to be tweaked. Please help. Thank you. The "start" value should round down and the stop value should round up. My code either rounds both up or down.
Willing to elaborate more if the above doesnt make sense.. with anyone willing to help.
Simply put it's two ways of thinking of rounding off a number. Ceiling rounds up to nearest integer. Floor rounds down to nearest integer. If the number is an integer, nothing happens.
It's easy to think about floor and ceil from the perspective of the number line.
Let's say you have some decimal number, (I'm going to be using this number as an example throughout my answer)

So, as you can see, the functions just return the nearest integer values.
floor returns the nearest lowest integer and ceil returns the nearest highest integer.
All real numbers are made of a characteristic (an integer part) and mantissa (a fractional part)
When floor a number, you can think of it as replacing the Mantissa with
and ceil can be thought of as replacing the mantissa with .
That's not a very popular way of thinking about it but it was the way I thought about it when I first started using it in programming.
Remember, the number remains the same when it is an integer.
ie, floor()
ceil(
)
Let's now look at the proper definitions along with the graphs for them.
Floor Function: Returns the greatest integer that is less than or equal to

Ceiling Function: Returns the least integer that is greater than or equal to

Don't let the infinite staircase scare you. It's much more simpler than it seems. Those "line-segments" that you see are actually called piecewise-step functions.
Simply, the black dot represents 'including this number' and the white represents 'excluding this number'. Meaning that each segment actually is from x to all numbers less than x+1.
Let's look at 2.31 and how it would look on both the graphs at once.
You can see that the line This is apples vs. oranges. In most languages/APIs, min/max take two (or more) inputs, and return the smallest/biggest. floor/ceil take one argument, and round it down or up to the nearest integer.
To my knowledge max and min are used on a collection, say an array of numbers. Floor and ceiling are used for single numbers. For example:
min(1, 2, 3, 4) => 1
max(1, 2, 3, 4) => 4
floor(3.5) => 3
ceiling(3.5) => 4
Average is most important! Floor and ceiling can be a BS sales tactic! Don’t ask the floor and ceiling unless you ask the average too!
$1 floor $750 ceiling says I can put a $3 card in that repack. Ask the average! The average is the most important number. If the seller makes up a fake average stay away! Pay attention! The seller doesn’t know the average of their repacks then you’re most likely getting a floor dollar amount value. 20 repacks cannot have an average of $200 and you keep pulling out $8 $10 cards. That’s not the average! Sit back and watch. If the breakers says average is $150 and they keep pulling out $30 cards. Then that breaker is FOS and is throwing out fake numbers to get you to buy in his break. Spend your money wisely! Don’t be manipulated! If the floor says $1 then you may get a $4 card oh well! 🤷🏽. What’s even better is when the breakers say you won’t get a $1 card they won’t do you like that. Then why have $1 floor in the first place. They Make that floor $20 but won’t because they repack $8 cards. Get it?
Might be stupid question, but this has always puzzled me about Java.
Why functions Math.floor(), Math.round() and Math.ceil() return double value?
I thought main point of those is to convert floating point number into whole number. So why not returning long or int? That way we don't have to manually cast everytime.
So I have this question from my class which I just don't understand.
1)Give two non-integer real numbers x and y for which
Ceiling(x) × y = x × Floor(y)
2)Prove that for all real x ,
Ceiling(x) − 1 = − Floor(-x) −1
Full marks can only be achieved by using indirect equality.
I really just don't understand this, any help would be appreciated.
edit: formatting
I know I can express floor(a) in many ways involving summation, ceiling functions, etc. Is there a way to express a general floor function without the use of the floor function itself or the ceiling function?
Need some help with understanding flooring and ceiling with integers in C (not C++, since that was the only thing that came up when I searched). Are integers default floored or ceiled in C, and why?
Forgive my lack of knowledge for the proper vocabulary. But would it be possible to write a floor or ceiling function with just x and y similar to how abs can be written as sqrt(x^2) or how the sign function can be written out as x/abs(x)? I tried to rationalize it, but I didn't get very far.