{"action":"created","comment":{"url":"https://api.github.com/repos/scala-js/scala-js/pulls/comments/28139344","id":28139344,"diff_hunk":"@@ -0,0 +1,284 @@\n+/*\n+ *  Ported by Alistair Johnson from https://github.com/gwtproject/gwt/blob/master/user/super/com/google/gwt/emul/java/math/Primality.java\n+ *  Original license copied below:\n+ */\n+\n+/*\n+ * Copyright 2009 Google Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+ * use this file except in compliance with the License. You may obtain a copy of\n+ * the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations under\n+ * the License.\n+ */\n+\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements. See the NOTICE file distributed with this\n+ * work for additional information regarding copyright ownership. The ASF\n+ * licenses this file to You under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations under\n+ * the License.\n+ *\n+ * INCLUDES MODIFICATIONS BY RICHARD ZSCHECH AS WELL AS GOOGLE.\n+ */\n+package java.math\n+\n+import java.util.Arrays\n+import java.util.Random\n+\n+/**\n+ * Provides primality probabilistic methods.\n+ */\n+object Primality {\n+  private val BITS = Array(\n+      0, 0, 1854, 1233, 927, 747, 627, 543, 480, 431, 393, 361, 335, 314, 295,\n+      279, 265, 253, 242, 232, 223, 216, 181, 169, 158, 150, 145, 140, 136,\n+      132, 127, 123, 119, 114, 110, 105, 101, 96, 92, 87, 83, 78, 73, 69, 64,\n+      59, 54, 49, 44, 38, 32, 26, 1)\n+\n+  /** All prime numbers with bit length lesser than 10 bits. */\n+  private val primes = Array[Int](2, 3, 5, 7, 11, 13, 17, 19, 23, 29,\n+      31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,\n+      103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,\n+      173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,\n+      241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313,\n+      317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397,\n+      401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467,\n+      479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569,\n+      571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643,\n+      647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733,\n+      739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823,\n+      827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,\n+      919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009,\n+      1013, 1019, 1021)\n+\n+  /**\n+   * It encodes how many i-bit primes there are in the table for {@code\n+   * i=2,...,10}. For example {@code offsetPrimes[6]} says that from index\n+   * {@code 11} exists {@code 7} consecutive {@code 6}-bit prime numbers in the\n+   * array.\n+   */\n+  private val offsetPrimes = Array(\n+      null, null, Array(0, 2), Array(2, 2), Array(4, 2), Array(6, 5), Array(11, 7),\n+      Array(18, 13), Array(31, 23), Array(54, 43), Array(97, 75))\n+\n+  /**\n+   * All {@code BigInteger} prime numbers with bit length lesser than 8 bits.\n+   */\n+  private val BIprimes =\n+    Array.tabulate[BigInteger](primes.length)(i => BigInteger.valueOf(primes(i)))\n+\n+  /**\n+   * A random number is generated until a probable prime number is found.\n+   *\n+   * @see BigInteger#BigInteger(int,int,Random)\n+   * @see BigInteger#probablePrime(int,Random)\n+   * @see #isProbablePrime(BigInteger, int)\n+   */\n+  def consBigInteger(bitLength: Int, certainty: Int, rnd: Random): BigInteger = {\n+    // PRE: bitLength >= 2\n+    // For small numbers get a random prime from the prime table\n+    if (bitLength <= 10) {\n+      val rp = offsetPrimes(bitLength)\n+      BIprimes(rp(0) + rnd.nextInt(rp(1)))\n+    } else {\n+      val shiftCount = (-bitLength) & 31\n+      var last = (bitLength + 31) >> 5\n+      val n = new BigInteger(1, last, new Array[Int](last))\n+      last -= 1","path":"javalib/src/main/scala/java/math/Primality.scala","position":104,"original_position":104,"commit_id":"a92f3b24c0b473f82ba0e05c017d34c2a439edf5","original_commit_id":"a92f3b24c0b473f82ba0e05c017d34c2a439edf5","user":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"body":"`val last = count - 1`","created_at":"2015-04-10T12:08:07Z","updated_at":"2015-04-10T12:08:07Z","html_url":"https://github.com/scala-js/scala-js/pull/1549#discussion_r28139344","pull_request_url":"https://api.github.com/repos/scala-js/scala-js/pulls/1549","_links":{"self":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/comments/28139344"},"html":{"href":"https://github.com/scala-js/scala-js/pull/1549#discussion_r28139344"},"pull_request":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/1549"}}},"pull_request":{"url":"https://api.github.com/repos/scala-js/scala-js/pulls/1549","id":31272316,"html_url":"https://github.com/scala-js/scala-js/pull/1549","diff_url":"https://github.com/scala-js/scala-js/pull/1549.diff","patch_url":"https://github.com/scala-js/scala-js/pull/1549.patch","issue_url":"https://api.github.com/repos/scala-js/scala-js/issues/1549","number":1549,"state":"open","locked":false,"title":"BigDecimal and BigInteger","user":{"login":"InTheNow","id":5887373,"avatar_url":"https://avatars.githubusercontent.com/u/5887373?v=3","gravatar_id":"","url":"https://api.github.com/users/InTheNow","html_url":"https://github.com/InTheNow","followers_url":"https://api.github.com/users/InTheNow/followers","following_url":"https://api.github.com/users/InTheNow/following{/other_user}","gists_url":"https://api.github.com/users/InTheNow/gists{/gist_id}","starred_url":"https://api.github.com/users/InTheNow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/InTheNow/subscriptions","organizations_url":"https://api.github.com/users/InTheNow/orgs","repos_url":"https://api.github.com/users/InTheNow/repos","events_url":"https://api.github.com/users/InTheNow/events{/privacy}","received_events_url":"https://api.github.com/users/InTheNow/received_events","type":"User","site_admin":false},"body":"Implements https://github.com/scala-js/scala-js/issues/373\r\n\r\nNotes: \r\n- There are four tests marked as xit, all relating to float infinity being casted to doubl infinity\r\n- There are a couple of comments of \"Todo:\" where some functionality _could_ go into main javalib.\r\n","created_at":"2015-03-16T18:45:35Z","updated_at":"2015-04-10T12:08:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"031eed65e50d46bb4429373dddfc8c6903fae858","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scala-js/scala-js/pulls/1549/commits","review_comments_url":"https://api.github.com/repos/scala-js/scala-js/pulls/1549/comments","review_comment_url":"https://api.github.com/repos/scala-js/scala-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scala-js/scala-js/issues/1549/comments","statuses_url":"https://api.github.com/repos/scala-js/scala-js/statuses/a92f3b24c0b473f82ba0e05c017d34c2a439edf5","head":{"label":"InTheNow:BigNumerics","ref":"BigNumerics","sha":"a92f3b24c0b473f82ba0e05c017d34c2a439edf5","user":{"login":"InTheNow","id":5887373,"avatar_url":"https://avatars.githubusercontent.com/u/5887373?v=3","gravatar_id":"","url":"https://api.github.com/users/InTheNow","html_url":"https://github.com/InTheNow","followers_url":"https://api.github.com/users/InTheNow/followers","following_url":"https://api.github.com/users/InTheNow/following{/other_user}","gists_url":"https://api.github.com/users/InTheNow/gists{/gist_id}","starred_url":"https://api.github.com/users/InTheNow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/InTheNow/subscriptions","organizations_url":"https://api.github.com/users/InTheNow/orgs","repos_url":"https://api.github.com/users/InTheNow/repos","events_url":"https://api.github.com/users/InTheNow/events{/privacy}","received_events_url":"https://api.github.com/users/InTheNow/received_events","type":"User","site_admin":false},"repo":{"id":16174535,"name":"scala-js","full_name":"InTheNow/scala-js","owner":{"login":"InTheNow","id":5887373,"avatar_url":"https://avatars.githubusercontent.com/u/5887373?v=3","gravatar_id":"","url":"https://api.github.com/users/InTheNow","html_url":"https://github.com/InTheNow","followers_url":"https://api.github.com/users/InTheNow/followers","following_url":"https://api.github.com/users/InTheNow/following{/other_user}","gists_url":"https://api.github.com/users/InTheNow/gists{/gist_id}","starred_url":"https://api.github.com/users/InTheNow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/InTheNow/subscriptions","organizations_url":"https://api.github.com/users/InTheNow/orgs","repos_url":"https://api.github.com/users/InTheNow/repos","events_url":"https://api.github.com/users/InTheNow/events{/privacy}","received_events_url":"https://api.github.com/users/InTheNow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/InTheNow/scala-js","description":"Scala.js, a Scala to JavaScript compiler","fork":true,"url":"https://api.github.com/repos/InTheNow/scala-js","forks_url":"https://api.github.com/repos/InTheNow/scala-js/forks","keys_url":"https://api.github.com/repos/InTheNow/scala-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/InTheNow/scala-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/InTheNow/scala-js/teams","hooks_url":"https://api.github.com/repos/InTheNow/scala-js/hooks","issue_events_url":"https://api.github.com/repos/InTheNow/scala-js/issues/events{/number}","events_url":"https://api.github.com/repos/InTheNow/scala-js/events","assignees_url":"https://api.github.com/repos/InTheNow/scala-js/assignees{/user}","branches_url":"https://api.github.com/repos/InTheNow/scala-js/branches{/branch}","tags_url":"https://api.github.com/repos/InTheNow/scala-js/tags","blobs_url":"https://api.github.com/repos/InTheNow/scala-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/InTheNow/scala-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/InTheNow/scala-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/InTheNow/scala-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/InTheNow/scala-js/statuses/{sha}","languages_url":"https://api.github.com/repos/InTheNow/scala-js/languages","stargazers_url":"https://api.github.com/repos/InTheNow/scala-js/stargazers","contributors_url":"https://api.github.com/repos/InTheNow/scala-js/contributors","subscribers_url":"https://api.github.com/repos/InTheNow/scala-js/subscribers","subscription_url":"https://api.github.com/repos/InTheNow/scala-js/subscription","commits_url":"https://api.github.com/repos/InTheNow/scala-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/InTheNow/scala-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/InTheNow/scala-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/InTheNow/scala-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/InTheNow/scala-js/contents/{+path}","compare_url":"https://api.github.com/repos/InTheNow/scala-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/InTheNow/scala-js/merges","archive_url":"https://api.github.com/repos/InTheNow/scala-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/InTheNow/scala-js/downloads","issues_url":"https://api.github.com/repos/InTheNow/scala-js/issues{/number}","pulls_url":"https://api.github.com/repos/InTheNow/scala-js/pulls{/number}","milestones_url":"https://api.github.com/repos/InTheNow/scala-js/milestones{/number}","notifications_url":"https://api.github.com/repos/InTheNow/scala-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/InTheNow/scala-js/labels{/name}","releases_url":"https://api.github.com/repos/InTheNow/scala-js/releases{/id}","created_at":"2014-01-23T14:24:12Z","updated_at":"2015-04-07T12:49:33Z","pushed_at":"2015-04-09T14:59:03Z","git_url":"git://github.com/InTheNow/scala-js.git","ssh_url":"git@github.com:InTheNow/scala-js.git","clone_url":"https://github.com/InTheNow/scala-js.git","svn_url":"https://github.com/InTheNow/scala-js","homepage":"http://www.scala-js.org/","size":7940,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scala-js:master","ref":"master","sha":"6bb21c20032a5d0d810b0b7769365f127ee45ea8","user":{"login":"scala-js","id":6039724,"avatar_url":"https://avatars.githubusercontent.com/u/6039724?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-js","html_url":"https://github.com/scala-js","followers_url":"https://api.github.com/users/scala-js/followers","following_url":"https://api.github.com/users/scala-js/following{/other_user}","gists_url":"https://api.github.com/users/scala-js/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-js/subscriptions","organizations_url":"https://api.github.com/users/scala-js/orgs","repos_url":"https://api.github.com/users/scala-js/repos","events_url":"https://api.github.com/users/scala-js/events{/privacy}","received_events_url":"https://api.github.com/users/scala-js/received_events","type":"Organization","site_admin":false},"repo":{"id":8272315,"name":"scala-js","full_name":"scala-js/scala-js","owner":{"login":"scala-js","id":6039724,"avatar_url":"https://avatars.githubusercontent.com/u/6039724?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-js","html_url":"https://github.com/scala-js","followers_url":"https://api.github.com/users/scala-js/followers","following_url":"https://api.github.com/users/scala-js/following{/other_user}","gists_url":"https://api.github.com/users/scala-js/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-js/subscriptions","organizations_url":"https://api.github.com/users/scala-js/orgs","repos_url":"https://api.github.com/users/scala-js/repos","events_url":"https://api.github.com/users/scala-js/events{/privacy}","received_events_url":"https://api.github.com/users/scala-js/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scala-js/scala-js","description":"Scala.js, the Scala to JavaScript compiler","fork":false,"url":"https://api.github.com/repos/scala-js/scala-js","forks_url":"https://api.github.com/repos/scala-js/scala-js/forks","keys_url":"https://api.github.com/repos/scala-js/scala-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scala-js/scala-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scala-js/scala-js/teams","hooks_url":"https://api.github.com/repos/scala-js/scala-js/hooks","issue_events_url":"https://api.github.com/repos/scala-js/scala-js/issues/events{/number}","events_url":"https://api.github.com/repos/scala-js/scala-js/events","assignees_url":"https://api.github.com/repos/scala-js/scala-js/assignees{/user}","branches_url":"https://api.github.com/repos/scala-js/scala-js/branches{/branch}","tags_url":"https://api.github.com/repos/scala-js/scala-js/tags","blobs_url":"https://api.github.com/repos/scala-js/scala-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scala-js/scala-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scala-js/scala-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/scala-js/scala-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scala-js/scala-js/statuses/{sha}","languages_url":"https://api.github.com/repos/scala-js/scala-js/languages","stargazers_url":"https://api.github.com/repos/scala-js/scala-js/stargazers","contributors_url":"https://api.github.com/repos/scala-js/scala-js/contributors","subscribers_url":"https://api.github.com/repos/scala-js/scala-js/subscribers","subscription_url":"https://api.github.com/repos/scala-js/scala-js/subscription","commits_url":"https://api.github.com/repos/scala-js/scala-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/scala-js/scala-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/scala-js/scala-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/scala-js/scala-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/scala-js/scala-js/contents/{+path}","compare_url":"https://api.github.com/repos/scala-js/scala-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scala-js/scala-js/merges","archive_url":"https://api.github.com/repos/scala-js/scala-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scala-js/scala-js/downloads","issues_url":"https://api.github.com/repos/scala-js/scala-js/issues{/number}","pulls_url":"https://api.github.com/repos/scala-js/scala-js/pulls{/number}","milestones_url":"https://api.github.com/repos/scala-js/scala-js/milestones{/number}","notifications_url":"https://api.github.com/repos/scala-js/scala-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scala-js/scala-js/labels{/name}","releases_url":"https://api.github.com/repos/scala-js/scala-js/releases{/id}","created_at":"2013-02-18T16:33:55Z","updated_at":"2015-04-09T19:39:16Z","pushed_at":"2015-04-10T10:46:28Z","git_url":"git://github.com/scala-js/scala-js.git","ssh_url":"git@github.com:scala-js/scala-js.git","clone_url":"https://github.com/scala-js/scala-js.git","svn_url":"https://github.com/scala-js/scala-js","homepage":"http://www.scala-js.org/","size":14927,"stargazers_count":1605,"watchers_count":1605,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":126,"mirror_url":null,"open_issues_count":43,"forks":126,"open_issues":43,"watchers":1605,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/1549"},"html":{"href":"https://github.com/scala-js/scala-js/pull/1549"},"issue":{"href":"https://api.github.com/repos/scala-js/scala-js/issues/1549"},"comments":{"href":"https://api.github.com/repos/scala-js/scala-js/issues/1549/comments"},"review_comments":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/1549/comments"},"review_comment":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/1549/commits"},"statuses":{"href":"https://api.github.com/repos/scala-js/scala-js/statuses/a92f3b24c0b473f82ba0e05c017d34c2a439edf5"}}}}