Javascript Math Floor Function

by top54u.com 16 Jul, 2008
Spotlight.....

Math Floor function of Javascript returns the nearest smaller value to the specified number. Math floor function means the floor value i.e. lower value for the specified value. Math.floor(x) function returns the lower nearest value for the specified number. Math.floor function truncates the decimal precision point values of the number and returns the smallest integer. If the specified number is an integer value then Javascript Math floor function returns the same value.

 

Syntax for Javascript Math Floor Function

 

Math.floor(x);

Math.floor function accepts value as number as returns nearest lower integer value for it.

 

 

Examples of Javascript Math Floor Function

 

 

<script language="javascript" type="text/javascript">

document.write(Math.floor(0.51) + "<br />");

document.write(Math.floor(2) + "<br />");

document.write(Math.floor(2.1) + "<br />");

document.write(Math.floor(2.84) + "<br />");

document.write(Math.floor(-2.44) + "<br />");

document.write(Math.floor(-6.44) + "<br />");

document.write(Math.floor(-6.94) + "<br />");

 

</script>

 

Output:

0
2
2
2
-3
-7
-7

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

8/23/2008 8:56:25 PM

OUR SPONSORS[+ advertise here]
related videos.....
recent posts.....
top54u ezines.....