-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for fractional numbers
- Loading branch information
1 parent
1c868c1
commit cd46683
Showing
9 changed files
with
107 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/*jshint node:true */ | ||
|
||
'use strict'; | ||
|
||
var R = require('./R'); | ||
|
||
var add = R.invoker(1, 'plus'); | ||
|
||
module.exports = Object.freeze({ | ||
add: add, | ||
|
||
indexOfSymbol: R.memoize(function(symbols) { | ||
return R.memoize(R.indexOf(R.__, symbols)); | ||
}), | ||
|
||
joinWithoutSep: R.join(''), | ||
joinWithDot: R.join('.'), | ||
|
||
splitByDot: R.split('.'), | ||
|
||
sum: function(big) { | ||
return R.reduce(add, big('0')); | ||
}, | ||
|
||
toString: R.invoker(0, 'toString') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/*jshint node:true */ | ||
|
||
'use strict'; | ||
|
||
var toBigFactory = require('to-decimal-arbitrary-precision'); | ||
|
||
var R = require('./R'); | ||
var U = require('./U'); | ||
|
||
var toDecimalRaw = R.curryN(5, function(mapper, big, symbols, base, n) { | ||
return R.pipe( | ||
R.map(U.indexOfSymbol(symbols)), | ||
R.addIndex(R.map)(mapper(big, base)), | ||
U.sum(big) | ||
)(n); | ||
}); | ||
|
||
module.exports = toDecimalRaw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/*jshint node:true */ | ||
|
||
'use strict'; | ||
|
||
var posNotation = require('positional-notation'); | ||
|
||
var R = require('./R'); | ||
|
||
module.exports = R.curryN(4, function(big, base, val, index) { | ||
return posNotation.raw(big, base, [-index - 1, val]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/*jshint node:true */ | ||
|
||
'use strict'; | ||
|
||
var tr = require('string-translate'); | ||
|
||
var R = require('./R'); | ||
var U = require('./U'); | ||
|
||
module.exports = R.memoize(function(defaultSymbols, symbols) { | ||
return R.identical(defaultSymbols, symbols) ? R.identity : tr(defaultSymbols, symbols); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters