Allow negative values for float and double
This commit is contained in:
parent
0a21e8ecb1
commit
b1e9ec82c5
1 changed files with 6 additions and 3 deletions
|
@ -43,7 +43,8 @@ make.typed = {
|
|||
*/
|
||||
float: function (limit = null) {
|
||||
let base = (limit !== null) ? random.number(limit) : random.number()
|
||||
return 'new Float32Array([' + (base + random.float()) + '])[0]'
|
||||
let value = random.chance(10) ? -(base + random.float()) : (base + random.float())
|
||||
return 'new Float32Array([' + value + '])[0]'
|
||||
},
|
||||
unrestrictedFloat: function (limit = null) {
|
||||
if (random.chance(100)) {
|
||||
|
@ -55,14 +56,16 @@ make.typed = {
|
|||
},
|
||||
double: function (limit = null) {
|
||||
let base = (limit !== null) ? random.number(limit) : random.number()
|
||||
return 'new Float64Array([' + (base + random.float()) + '])[0]'
|
||||
let value = random.chance(10) ? -(base + random.float()) : (base + random.float())
|
||||
return 'new Float64Array([' + value + '])[0]'
|
||||
},
|
||||
unrestrictedDouble: function (limit = null) {
|
||||
if (random.chance(100)) {
|
||||
return random.pick([NaN, +Infinity, -Infinity])
|
||||
} else {
|
||||
let base = (limit !== null) ? random.number(limit) : random.number()
|
||||
return 'new Float64Array([' + (base + random.float()) + '])[0]'
|
||||
let value = random.chance(10) ? -(base + random.float()) : (base + random.float())
|
||||
return 'new Float64Array([' + value + '])[0]'
|
||||
}
|
||||
},
|
||||
any: function () {
|
||||
|
|
Loading…
Reference in a new issue