MCPcopy Index your code
hub / github.com/plotly/plotly.js / rationalize

Function rationalize

stackgl_modules/index.js:2373–2391  ·  view source on GitHub ↗
(numer, denom)

Source from the content-addressed store, hash-verified

2371module.exports = rationalize
2372
2373function rationalize(numer, denom) {
2374 var snumer = sign(numer)
2375 var sdenom = sign(denom)
2376 if(snumer === 0) {
2377 return [num2bn(0), num2bn(1)]
2378 }
2379 if(sdenom === 0) {
2380 return [num2bn(0), num2bn(0)]
2381 }
2382 if(sdenom < 0) {
2383 numer = numer.neg()
2384 denom = denom.neg()
2385 }
2386 var d = numer.gcd(denom)
2387 if(d.cmpn(1)) {
2388 return [ numer.div(d), denom.div(d) ]
2389 }
2390 return [ numer, denom ]
2391}
2392
2393
2394/***/ }),

Callers 5

addFunction · 0.85
divFunction · 0.85
makeRationalFunction · 0.85
mulFunction · 0.85
subFunction · 0.85

Calls 2

num2bnFunction · 0.85
signFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…