bdiv_s32.inc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. type
  2. { TSInt32Bit1Test }
  3. TSInt32Bit1Test = class(TSInt32DivTest)
  4. protected
  5. function GetDivisor: Integer; override;
  6. procedure DoTestIteration(Iteration: Integer); override;
  7. public
  8. function TestTitle: shortstring; override;
  9. end;
  10. { TSInt32Bit1ModTest }
  11. TSInt32Bit1ModTest = class(TSInt32ModTest)
  12. protected
  13. function GetDivisor: Integer; override;
  14. procedure DoTestIteration(Iteration: Integer); override;
  15. public
  16. function TestTitle: shortstring; override;
  17. end;
  18. { TSInt32Bit100Test }
  19. TSInt32Bit100Test = class(TSInt32DivTest)
  20. protected
  21. function GetDivisor: Integer; override;
  22. procedure DoTestIteration(Iteration: Integer); override;
  23. public
  24. function TestTitle: shortstring; override;
  25. end;
  26. { TSInt32Bit100ModTest }
  27. TSInt32Bit100ModTest = class(TSInt32ModTest)
  28. protected
  29. function GetDivisor: Integer; override;
  30. procedure DoTestIteration(Iteration: Integer); override;
  31. public
  32. function TestTitle: shortstring; override;
  33. end;
  34. { TSInt32Bit1Test }
  35. function TSInt32Bit1Test.TestTitle: shortstring;
  36. begin
  37. Result := 'Signed 32-bit division by 1';
  38. end;
  39. function TSInt32Bit1Test.GetDivisor: Integer;
  40. begin
  41. Result := 1;
  42. end;
  43. procedure TSInt32Bit1Test.DoTestIteration(Iteration: Integer);
  44. var
  45. Numerator, Answer: Integer;
  46. Index, X: Integer;
  47. begin
  48. Index := Iteration and $FF;
  49. case Index of
  50. 0:
  51. Numerator := -2147483648;
  52. 1:
  53. Numerator := -2147483600;
  54. 2:
  55. Numerator := -2147483599;
  56. 253:
  57. Numerator := 2147483599;
  58. 254:
  59. Numerator := 2147483600;
  60. 255:
  61. Numerator := 2147483647;
  62. else
  63. Numerator := Index - 128;
  64. end;
  65. FInputArray[Index] := Numerator;
  66. for X := 0 to INTERNAL_LOOPS - 1 do
  67. Answer := Numerator div 1;
  68. FResultArray[Index] := Answer;
  69. end;
  70. { TSInt32Bit1ModTest }
  71. function TSInt32Bit1ModTest.TestTitle: shortstring;
  72. begin
  73. Result := 'Signed 32-bit modulus by 1';
  74. end;
  75. function TSInt32Bit1ModTest.GetDivisor: Integer;
  76. begin
  77. Result := 1;
  78. end;
  79. procedure TSInt32Bit1ModTest.DoTestIteration(Iteration: Integer);
  80. var
  81. Numerator, Answer: Integer;
  82. Index, X: Integer;
  83. begin
  84. Index := Iteration and $FF;
  85. case Index of
  86. 0:
  87. Numerator := -2147483648;
  88. 1:
  89. Numerator := -2147483600;
  90. 2:
  91. Numerator := -2147483599;
  92. 253:
  93. Numerator := 2147483599;
  94. 254:
  95. Numerator := 2147483600;
  96. 255:
  97. Numerator := 2147483647;
  98. else
  99. Numerator := Index - 128;
  100. end;
  101. FInputArray[Index] := Numerator;
  102. for X := 0 to INTERNAL_LOOPS - 1 do
  103. Answer := Numerator mod 1;
  104. FResultArray[Index] := Answer;
  105. end;
  106. { TSInt32Bit100Test }
  107. function TSInt32Bit100Test.TestTitle: shortstring;
  108. begin
  109. Result := 'Signed 32-bit division by 100';
  110. end;
  111. function TSInt32Bit100Test.GetDivisor: Integer;
  112. begin
  113. Result := 100;
  114. end;
  115. procedure TSInt32Bit100Test.DoTestIteration(Iteration: Integer);
  116. var
  117. Numerator, Answer: Integer;
  118. Index, X: Integer;
  119. begin
  120. Index := Iteration and $FF;
  121. case Index of
  122. 0:
  123. Numerator := -2147483648;
  124. 1:
  125. Numerator := -2147483600;
  126. 2:
  127. Numerator := -2147483599;
  128. 253:
  129. Numerator := 2147483599;
  130. 254:
  131. Numerator := 2147483600;
  132. 255:
  133. Numerator := 2147483647;
  134. else
  135. Numerator := Index - 128;
  136. end;
  137. FInputArray[Index] := Numerator;
  138. for X := 0 to INTERNAL_LOOPS - 1 do
  139. Answer := Numerator div 100;
  140. FResultArray[Index] := Answer;
  141. end;
  142. { TSInt32Bit100ModTest }
  143. function TSInt32Bit100ModTest.TestTitle: shortstring;
  144. begin
  145. Result := 'Signed 32-bit modulus by 100';
  146. end;
  147. function TSInt32Bit100ModTest.GetDivisor: Integer;
  148. begin
  149. Result := 100;
  150. end;
  151. procedure TSInt32Bit100ModTest.DoTestIteration(Iteration: Integer);
  152. var
  153. Numerator, Answer: Integer;
  154. Index, X: Integer;
  155. begin
  156. Index := Iteration and $FF;
  157. case Index of
  158. 0:
  159. Numerator := -2147483648;
  160. 1:
  161. Numerator := -2147483600;
  162. 2:
  163. Numerator := -2147483599;
  164. 253:
  165. Numerator := 2147483599;
  166. 254:
  167. Numerator := 2147483600;
  168. 255:
  169. Numerator := 2147483647;
  170. else
  171. Numerator := Index - 128;
  172. end;
  173. FInputArray[Index] := Numerator;
  174. for X := 0 to INTERNAL_LOOPS - 1 do
  175. Answer := Numerator mod 100;
  176. FResultArray[Index] := Answer;
  177. end;