UNPKG
big-rat
Version:
latest (1.0.4)
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.0.0
A big integer rational number
github.com/rat-nest/big-rat
rat-nest/big-rat
big-rat
/
lib
/
num-to-bn.js
16 lines
(12 loc)
•
252 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict'
var
BN
=
require
(
'bn.js'
)
var
db =
require
(
'double-bits'
)
module
.
exports
= num2bn
function
num2bn
(
x
) {
var
e = db.
exponent
(x)
if
(e <
52
) {
return
new
BN
(x) }
else
{
return
(
new
BN
(x *
Math
.
pow
(
2
,
52
-e))).
ushln
(e-
52
) } }