js:parseInt (7/2)
js: Math.ceil(7/2)
js: Math.round(7/2)
js: Math.floor(7/2)
In fact, it is to use regular expressions.
"^\\d+$" // Non-negative integer (positive integer+0)
"^[0-9]* [1-9][0-9]*$"//Positive integer
"^((-\\d+)|(0+))$" // Not positive Integer (negative integer+ 0)
"^-[0-9]*[1-9][0-9]*$"//Negative integers //
Non-negative floating point number (positive floating point number+0
)"^(([0-9]+\\.[0- 9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9 ]*[1-9][0-9]*))$" //Positive floating point number ?)|(0+(\\.0+)?))$"//
Non-positive floating point number (negative floating point number+0
)"^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9 ]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"//Negative floating point number"^(-?\\d+)(\\.\\d+)?$"//
Floating point numberExample
var r = /^[0-9]*[1-9][0-9]*$///Positive integer
trueor
false## Beautiful text and beautiful pictures
##The above is the content. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!