Bản mẫu:Floor
Tài liệu bản mẫu
Implements the mathematical floor function, i.e. returns the input value if it is an integer, otherwise returns the largest integer below the input value.
For positive numbers, the decimals will be simply dropped. For negative numbers, it will also truncate the displayed decimals but the integer part of the absolute value displayed is incremented. This is the mathematical definition of the IEEE rounding mode toward minus infinity.
- Usage:
- {{Floor|value}}.
Due to the new built-in floor function the template only provides the minor convenience of writing {{Floor|value}} instead of {{#expr:floor(value)}}; inside the expression of #expr or #ifexpr it is not useful, since "floor(value)" is shorter than "{{Floor|value}}".
- Examples:
- {{Floor|3.9}} = 3.
- {{Floor|3.5}} = 3.
- {{Floor|3.1}} = 3.
- {{Floor|3.0}} = 3.
- {{Floor|1.0}} = 1.
- {{Floor|0.9}} = 0.
- {{Floor|0.5}} = 0.
- {{Floor|0.1}} = 0.
- {{Floor|0.0}} = 0.
- {{Floor|-0.1}} = -1.
- {{Floor|-0.5}} = -1.
- {{Floor|-0.9}} = -1.
- {{Floor|-1.0}} = -1.
- {{Floor|-3.0}} = -3.
- {{Floor|-3.2}} = -4.
- {{Floor|-3.5}} = -4.
- {{Floor|-3.9}} = -4.
Note:
- {{Floor|0.99999999999999983}} = 0 (OK).
- {{Floor|0.99999999999999999}} = 1 (wrong but comes from limited floating point precision, the input is rounded to 1 before applying the floor function)
"{{#expr:floor 0.99999999999999999}}"
cho ra "1" [1] (ditto)"{{#expr:floor (1-1e-17)}}"
cho ra "1" [2] (ditto)"{{#expr:floor 0.9999999999999999444888487687422}}"
cho ra "1" [3] (ditto)"{{#expr:floor 0.9999999999999999444888487687421}}"
cho ra "0" [4] (OK)"{{#expr:floor (1-1e-16)}}"
cho ra "0" [5] (OK)
Correspondingly:
"{{#expr:1- 0.9999999999999999444888487687422}}"
cho ra "0" [6]"{{#expr:1- 0.9999999999999999444888487687421}}"
cho ra "1.1102230246252E-16" [7]
- {{Floor|-0.99999999999999983}} = -1 (OK).
- {{Floor|-1.00000000000000001}} = -1 (wrong but comes from limited floating point precision, the input is rounded to -1 before applying the floor function).
num | floor | ceil |
---|---|---|
0.999999999999999444888487687421 | 0 | Bản mẫu:Ceil |
0.999999999999999444888487687422 | 1 | Bản mẫu:Ceil |
0.(322)01 | -1 | Bản mẫu:Ceil |
0.(323)01 | -0 | Bản mẫu:Ceil |
- See also:
- Template:Ceil
- Template:Rounddown
🔥 Top keywords: Đài Truyền hình Kỹ thuật số VTCTrang ChínhGiỗ Tổ Hùng VươngTrương Mỹ LanĐặc biệt:Tìm kiếmHùng VươngVương Đình HuệUEFA Champions LeagueKuwaitChiến dịch Điện Biên PhủFacebookĐài Truyền hình Việt NamTrần Cẩm TúĐội tuyển bóng đá quốc gia KuwaitGoogle DịchViệt NamCúp bóng đá U-23 châu ÁCúp bóng đá U-23 châu Á 2024Real Madrid CFBảng xếp hạng bóng đá nam FIFACleopatra VIITô LâmTim CookNguyễn Phú TrọngHồ Chí MinhHai Bà TrưngManchester City F.C.VnExpressChủ tịch nước Cộng hòa xã hội chủ nghĩa Việt NamNguyễn Ngọc ThắngĐền HùngCúp bóng đá trong nhà châu Á 2024Võ Văn ThưởngOne PieceLịch sử Việt NamCuộc đua xe đạp toàn quốc tranh Cúp truyền hình Thành phố Hồ Chí Minh 2024Phạm Minh ChínhTikTokĐinh Tiên Hoàng