Trang bản mẫu bị khóa vĩnh viễn

Bản mẫu:Floor

Bách khoa toàn thư mở Wikipedia
Bước tới điều hướng Bước tới tìm kiếm
Tài liệu bản mẫu[xem] [sửa] [lịch sử] [làm mới]

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: