Template:Rndpad

0. If amount exceeds - 85 billion or rounding exceeds 100-thousands (< -5) then - this template invokes Template:Rnd & allows scientific - notation for amounts above 85 billion. Otherwise, it rounds - amounts very quicky, using only the 1 subtemplate , - which ensures pad with trailing zeros in decimals (x.x00). - The expansion depth is 4 of the 40 expansion depth limit, - for amounts < 85 billion. - - NOTE L1: The limit to upper rounding is -11 for hundreds of -  billions. The max number to still allow padded end-zeroes -  "000" is 85 billion, due to scientific notation being shown -  for the upper half of the digits when more than 85 billion. -  Numbers >99,999 are split by modulo: {1} round {2} mod 1E5. - - NOTE N2: For smaller numbers & {2} < 1, will use -- template  to pad any trailing decimal zeroes. -- But, for amounts over 85 billion, using  will -  invoke up to 9 subtemplates, among the following: -      Template:Order_of_magnitude (view source) (protected) -      Template:Order_of_magnitude/x (view source) (protected) -      Template:Rnd (view source) (protected) -      Template:Rnd/- (view source) (protected) -      Template:Rnd/b1 (view source) (protected) -      Template:Rnd/b-1 (view source) (protected) -      Template:Rnd/c6dec0 (view source) (protected) -      Template:Rnd/c8dec0 (view source) (protected) -      Template:Rnd/d (view source) (protected) -      Template:Rnd/e+ (view source) (protected) -  Those subtemplates might exceed the template-nesting limit, -  such as inside nested infoboxes with 3-level nested-if -  expressions (assuming limit of 40 nested if-expressions). - - NOTE F3: The adjustment adds 0.000000001 to fix floor(x). -  The math function floor(x) experiences a bug whenever -  numbers are close to a whole digit, yet floor to 1 less: -   = 2 -   but floor ( (round)/100000) = 1. -  Even though an amount rounded -5 as 200 thousand & divided -  by 100 thousand, shows as "2", floor of that can be "1". -  That is why 1E-9 (0.000000001) is added to fix floor(x). -  Exact: 2 - (180333 round -5)/10E5 = 2.2204460492503E-16 - - NOTE R4: Rounding by a rounded count: Parentheses are used -  around the round-digit count to allow an expression, such -  as "" to be a rounded count. The -  parentheses ensure the "round 0" will apply to 0.5 as 1, -  rather than have 0.5 enter into the nearby calculation, as -   "4.16 round 0.5 round 0" versus "4.16 round (0.5 round 0)". -  Otherwise, the 1st round has precedence: "4.16 round 0.5". - -============================================================= -HISTORY: -11Mar10 Created to round to 10 billion as 10 digits, pad end 0. -11Mar10 Put NOTES comments to explain template coding. -11Mar10 Put HISTORY comments to log major changes. -11Mar10 Changed to use {rnd} when round less than -4. -11Mar10 Changed to round 11-digit form, up to 85 billion. -20Nov10 Changed to allow round -5 up to xx,951,000 of million. -11Jan11 Fixed rounded-up portions >999,999 to use. -11Jan11 Fixed to split digits >99,999 only after rounding. -11Jan11 Fixed to put 5 zeroes if any portion rounds > 99,999. -11Jan11 Fixed to put 5 zeroes if rounding count < -4. -11Jan11 Fixed floor(x) math bug by adding 1E-9 (0.000000001). -16Jan11 Fixed for negative exponents, abs(x) < 0.0000001. -18Jan11 Removed use of {formatnum:} to avoid commas. -19Jan11 Put many parentheses "" to round by an expression. -20Jan11 Put #expr in {rnd/-} parms to cut argument size 60%. -18Feb11 Fixed for whole billions to allow round -6 to -11. -20Feb11 Numbers >99,999 are split by: {1} round {2} mod 1E5. -20Feb11 Fixed rounding bug by: ({1} round {2})+1E-9 mod 1E5. -20Feb11 Fixed whole 100-thousands "00000" by rounding first. -20Feb11 Used quick {doc_short} rather than {documentation}. - -->