, because the range of float values is usually larger than the integer.
Example 1. Floor () example
echo floor (4.3); 4
echo Floor (9.999); 9
?>
Three, round-the floating-point number rounding
Description
Float round (float val [, int precision])
Returns the result of rounding Val based on the specified precision precision (number of digits after decimal point). Precision can also be negativ
thanintegerbe big. Example1. Floor() ExamplePHPEcho Floor(4.3);//4 Echo Floor(9.999);//9?>Third,round-Rounding out the floating-point numbersfloat round(floatVal [,int precision]) Returns the result of rounding Val based on the specified precision precision (number of digits after decimal point). Precision can also be negative or 0 (the default value). Example1.round() ExamplePHPEcho round(3.4);/
Reprint Source: HTTP://BLOG.CSDN.NET/YF210YF
Matlab takes the whole function: fix, floor, ceil, round. The rounding function is useful in programming. First, take the whole function 1. To 0 rounding (truncated rounding)
fix-to 0 rounding (Round towards zero);
>> Fix (3.6)
Ans = 3 2. Negative Infinity
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————Code1 DOCTYPE HTML>2 HTML>3 Head>4 Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/>5 title>title>6 Scriptt
11. He's smarter ...2 37 82. Friends who will use new things .... But we need ie5.5+.only supported. 9 Ten - the3after summarizing, I wrote a general method of JavaScript rounding with multiple digits. - - //num represents the number to be rounded, and V represents the number of decimal digits to keep. - functiondecimal (NUM,V) + { - varVV = Math.pow (10, V); + returnMath.Round (NUM*VV)/vv; A}js-
Math.Round (45.367,2) //Returns 45.37math.round (45.365, 2) // Returns 45.36C # round () is not our Chinese understanding of rounding, is the foreigner's rounding, is in line with the IEEE standard rounding, specifically four six into, the following is in line with the Chinese understand the roundingMath.Round (45.367,2, Midpointrounding.awayfromzero)
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————Code1 DOCTYPE HTML>2 HTML>3 Head>4 Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/>5 title>title>6 Scriptt
Private float Convertfloat4se5ru (float flotvalue) {int ivalue = (int) math.round (Flotvalue * 10000); Two digits before the decimal point are moved forward and roundedFlotvalue = (float) (ivalue/10000.00f);return flotvalue;}Disclaimer: The above text is "Wuhan Han Code Technology Co., Ltd." original, reproduced when must be marked the source.Technology sharing. To communicate with you and me. Progress together!Www.hanma-scan.com WinCE C # Programming, the float type is rounded to retain two
Tags: partial ast decimal trunc symbol date Max input roundTake the whole function:1. Trunc (value,precision) intercepts a number by precision (precision) and does not perform rounding operations.Returns the X value of the truncated to Y decimal places: Trunc (X,[y]): select trunc(23.33)
------------
23 2, round (value,precision) input the value [rounding rounding
//Way One:Doublef = 3.1516; BigDecimal b=NewBigDecimal (f);DoubleF1 = B.setscale (2, bigdecimal.round_half_up). Doublevalue (); //Way Two:NewJava.text.DecimalFormat ("#.00"). Format (3.1415926);//#.00 represents two decimal places #.0000 four decimal places and so on ...//Way Three:DoubleD = 3.1415926; String result= String.Format ("%.2f", d);//%.2f%. Indicates that any number of digits before the decimal point of 2 indicates that the result of the two-bit decimal format is F for floating-point.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.