For a certain program I wish to create, I need a floor function. Floor takes the number and cuts off the decimal, unlike rounding. Rouding can raise the number.
So...
floor(3.7) == 3
<round(3.7)> == 4
floor(3.252) == 3
<round(3.252)> = 3
So yeah. How would I recreate the floor function?
Offline
ElMikkino wrote:
GAH!!! Complicated Maths!!!!!!
Not really, he is just trying to replicate a Math method that are part of most programming languages. Here is a list of math methods.
Math.PI calls the number that is the circumference of a circle (That number is 3.14159265) that is known as PI
Math.ceil rounds a number up
Math.floor rounds a number down
Math.round rounds a number up if it's decimal value is greater or equal to 0.5 otherwise it's rounded down
Math.abs if a number is negative this math method will make it positive
Math.sqrt finds the square root of a number
Math.pow(x,y) x is raised by the power of y
Math.max finds the maximum of 2 numbers
Math.min finds the minimum of 2 numbers
Math.random generates a random number from 0 to 0.9999....
//Trigonometry math functions
Math.sin Calls the sin function
Math.cos calls the cosine function
Math.tan calls the tangent function
There are also a few more math functions that exist.
Last edited by archmage (2007-10-21 13:37:24)
Offline
ElMikkino wrote:
Math.abs, Math.sqrt, Math.pow, Math.tan and Math.sin sound wrong....
How do they sound wrong? I don't see what you mean.
Offline
ElMikkino wrote:
When you say them out loud, they do. Like, what if math had abs?! Or math got a tan?! Or math squirted stuff?!
Yea, programming languages like to use shorter words instead of saying the entire word like absolute or tangent or square root.
To print in a line of text in java you would say println instead of printline
Offline