स्वतन्त्र विश्वकोश, नेपाली विकिपिडियाबाट
Jump to navigation Jump to search

This is an auxiliary template of Template:Rnd, called if the number, after rounding, is positive. Thus this description is about internal details only.

Its first parameter is the result of regular rounding with #expr and the function round (but if written in scientific format, as expression not always evaluating to the exact round number, see below), its second the rounding parameter, and its third the value of the condition that the rounding parameter is positive.

It calls one of the following templates, passing on the first and second parameter:

where the last digit is the value of the condition that the rounding parameter is positive, and the digit after the c depends on the range of the rounded number:

  • less than 1e-4: 2 (only possible if the rounding parameter is positive)
  • from 1e-4 to 1e5: 4
  • from 1e5 to 1e9: 6 if the number is a multiple of 1e5, otherwise 4
  • 1e9 or more: 8

Multiples of 1e5 between 1e5 and 1e9 are treated separately to avoid scientific notation.

Examples[सम्पादन गर्ने]

  • {{rnd/b1|.0008|5|1}} → 0.00080
  • {{rnd/b1|1E+5|-5|0}} → 100000
  • {{rnd/b1|1.2E+6|-5|0}} → 1200000
  • {{rnd/b1|4.1E+6|10|1}} → 4100000.0000000000
  • {{rnd/b1|1540000000|-5|0}} → 1.5400×109
  • {{rnd/b1|1542689271|2|1}} → 1.54268927100×109

Notes[सम्पादन गर्ने]

This template checks whether the exact 14-digit number that the input value represents (not to be confused with the float value to which it evaluates) is a multiple of 100,000. It does this by comparing the number with that rounded to a multiple of 100,000. The comparison is done after applying #expr to both sides. Experiments suggest that {{#expr:{{#expr:f}}}} gives the same string for all floats f for which {{#expr:f}} mathematically represents the same number, see m:Help:Format produced by expr#Categorizing floats by the mathematical value of the string produced by expr.