2017-04-22 22:49:49 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2017-04-25 15:19:25 +00:00
|
|
|
make.number = {
|
2017-04-22 22:49:49 +00:00
|
|
|
bool: function () {
|
2017-04-25 22:21:31 +00:00
|
|
|
return random.bool()
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
|
|
|
float: function () {
|
2017-04-25 22:21:31 +00:00
|
|
|
let n
|
2017-04-22 22:49:49 +00:00
|
|
|
if (random.chance(32)) {
|
|
|
|
switch (random.number(4)) {
|
|
|
|
case 0:
|
2017-04-25 22:21:31 +00:00
|
|
|
n = random.range(Number.MAX_VALUE, Number.MIN_VALUE)
|
|
|
|
break
|
2017-04-22 22:49:49 +00:00
|
|
|
case 1:
|
2017-04-25 22:21:31 +00:00
|
|
|
n = Math.pow(10, 1) / Math.pow(10, random.number(307))
|
|
|
|
break
|
2017-04-22 22:49:49 +00:00
|
|
|
case 2:
|
2017-04-25 22:21:31 +00:00
|
|
|
n = Math.pow(2, random.float() * random.float() * 64)
|
|
|
|
break
|
2017-04-22 22:49:49 +00:00
|
|
|
case 3:
|
2017-04-25 22:21:31 +00:00
|
|
|
n = Math.pow(10, random.range(1, 9)) / Math.pow(10, random.range(1, 9))
|
|
|
|
break
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
2017-04-25 22:21:31 +00:00
|
|
|
return n
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
|
|
|
switch (random.number(6)) {
|
|
|
|
default:
|
2017-04-25 22:21:31 +00:00
|
|
|
n = random.float()
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
2017-04-25 22:21:31 +00:00
|
|
|
return n
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
2017-06-10 03:51:41 +00:00
|
|
|
range: function () {
|
|
|
|
return random.pick([1, 2, 3, 4, 6, 8, 16, 32, 64, make.number.tiny])
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
2017-06-10 03:51:41 +00:00
|
|
|
tiny: function () {
|
2017-04-25 22:21:31 +00:00
|
|
|
return Math.pow(2, random.number(12))
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
2017-06-10 03:51:41 +00:00
|
|
|
unsigned: function () {
|
2017-04-22 22:49:49 +00:00
|
|
|
if (random.chance(2)) {
|
2017-04-25 22:21:31 +00:00
|
|
|
return Math.abs(make.number.any())
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
2017-04-25 22:21:31 +00:00
|
|
|
return Math.pow(2, random.number(65)) + random.number(3) - 1
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
2017-06-10 03:51:41 +00:00
|
|
|
even: function (number) {
|
2017-04-25 22:21:31 +00:00
|
|
|
return number % 2 === 1 ? ++number : number
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
2017-06-08 02:26:28 +00:00
|
|
|
any: function () {
|
2017-04-22 22:49:49 +00:00
|
|
|
let value = random.choose([
|
2017-04-25 15:19:25 +00:00
|
|
|
[10, make.number.float],
|
2017-06-10 03:51:41 +00:00
|
|
|
[10, [make.number.range, make.number.tiny]],
|
|
|
|
[1, make.number.unsigned]
|
2017-04-25 22:21:31 +00:00
|
|
|
])
|
|
|
|
return random.chance(10) ? -value : value
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
2017-04-25 22:21:31 +00:00
|
|
|
}
|