テンプレート:Divint

2015年3月14日 (土) 12:15時点におけるNijcadmin (トーク | 投稿記録)による版 (1版)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)


This template divides an integer entered as a single parameter or with two parameters like in Template:Trunc, by an integer which is representable as float. For integers which are in absolute value less than 2^63, with results which are in absolute value between 2^53 and 2^63, the result is the nearest integer, which is more accurate than regular division of floats (rounding to float) and even division of numbers of type integer (exact if the mathematical result is an integer, but with rounding of the integers and rounding of the result to float).

Examples:

  • {{divint|8|3}} → 2.6666666666666665
  • {{divint|8e9|3}} → 2,666,666,666.6666665
  • {{divint|8e10|3}} → 26,666,666,666.666668 (note that while this shows the resulting float exactly, this float is the result of the regular rounding of the quotient)
  • {{divint|8e11|3}} → 266,666,666,666.66666
  • {{divint|8e12|3}} → 2,666,666,666,666.6665
  • {{divint|8e13|3}} → 26,666,666,666,666.668
  • {{divint|8e14|3}} → 266,666,666,666,666.66
  • {{divint|8e15|3}} → 2,666,666,666,666,666.5
  • {{divint|8e16|3}} → 26,666,666,666,666,668; compare: {{numf|8e16/3}} → 26,666,666,666,666,668
  • {{divint|8e17|3}} → 266,666,666,666,666,660; compare: {{numf|8e17/3}} → 266,666,666,666,666,660
  • {{divint|8e18|3}} → 2,666,666,666,666,666,500; compare: {{numf|8e18/3}} → 2,666,666,666,666,666,500
  • {{divint|8e19|3}} → 26,666,666,666,666,670,000
  • {{divint|1234567890|61235|3}} → 41,152,263,020,411.664
  • {{divint|1234567890|661235|3}} → 411,522,630,220,411.7
  • {{divint|1234567890|6661235|3}} → 4,115,226,302,220,412
  • {{divint|1234567890|66661235|3}} → 41,152,263,022,220,420
    • compare: {{numf|(trunc1234567890e8+trunc66661235)/3}} → 41,152,263,022,220,410
  • {{divint|1234567890|666661235|3}} → 411,522,630,222,220,400
    • compare: {{numf|(trunc1234567890e9+trunc666661235)/3}} → 411,522,630,222,220,350
  • {{divint|1234567890|6666661235|3}} → 4,115,226,302,222,221,000
  • {{divint|1234567890|66666661235|3}} → 41,152,263,022,222,220,000
  • {{divint|3,333,333,33|3,333,333,332|3}} → 1,111,111,111,111,111,200
  • {{divint|3,333,333,33|3,333,333,333|3}} → 1,111,111,111,111,111,200
  • {{divint|3,333,333,33|3,333,333,334|3}} → 1,111,111,111,111,111,200
  • {{divint|3,333,333,33|3,333,333,335|3}} → 1,111,111,111,111,111,200
  • {{divint|3,333,333,33|3,333,333,336|3}} → 1,111,111,111,111,111,200
  • {{divint|3,333,333,33|3,333,333,337|3}} → 1,111,111,111,111,111,200
  • {{divint|3,333,333,33|3,333,333,338|3}} → 1,111,111,111,111,111,200
  • {{divint|3,333,333,33|3,333,333,339|3}} → 1,111,111,111,111,111,200
  • {{divint|3,333,333,33|3,333,333,340|3}} → 1,111,111,111,111,111,200
  • {{divint|1e19|3}} → 3,333,333,333,333,333,500
  • {{divint|1234567890|666661235|987654321}} → 1,249,999,989.2843695
  • {{divint|1234567890|6666661235|987654321}} → 12,499,999,892.843744
  • {{divint|1234567890|66666661235|987654321}} → 124,999,998,928.43748
  • {{divint|1234567890|66666661235|1e20}} → 1.2345678906666666
  • {{divint|1e18|1}} → 1,000,000,000,000,000,000
  • {{divint|1e18|2}} → 500,000,000,000,000,000
  • {{divint|1e18|3}} → 333,333,333,333,333,300
  • {{divint|1e18|4}} → 250,000,000,000,000,000
  • {{divint|1e18|5}} → 200,000,000,000,000,000
  • {{divint|1e18|6}} → 166,666,666,666,666,660
  • {{divint|1e18|7}} → 142,857,142,857,142,860
  • {{divint|1e18|8}} → 125,000,000,000,000,000
  • {{divint|1e18|9}} → 111,111,111,111,111,100
  • {{divint|1e18|10}} → 100,000,000,000,000,000
  • {{divint|1e18|11}} → 90,909,090,909,090,910
  • {{divint|1e18|12}} → 83,333,333,333,333,330
  • {{divint|1e18|13}} → 76,923,076,923,076,930
  • {{divint|1e18|14}} → 71,428,571,428,571,430
  • {{divint|899999999|9999984049|12345}} → 729,040,097,205,345
  • {{divint|899999999|9999990197|12345}} → 729,040,097,205,345.5
  • {{divint|899999999|9999990198|12345}} → 729,040,097,205,345.5
  • {{divint|899999999|9999991200|12345}} → 729,040,097,205,345.5
  • {{divint|899999999|9999991300|12345}} → 729,040,097,205,345.6
  • {{divint|899999999|9999996369|12345}} → 729,040,097,205,346
  • {{divint|899999999|9999996370|12345}} → 729,040,097,205,346