UNPKG

theorem.js

Version:

A Math library for computation in JavaScript

55 lines (54 loc) 3.1 kB
c(name, n = 15) { const numbers = { "alphaParticleMass": "6.64465675e-27", "atomicMass": "1.660538921e-27", "Avogadro": "6.02214129e23", "Boltzmann": "1.3806488e-23", "conductanceQuantum": "7.7480917346e-5", "e": "2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260595630738132328627943490763233829880753195251019011573834187930702154089149934884167509244761460668", "earth-moon": "384401", "earth-sun": "1.496e8", "earthMass": "5.974e+24", "earthRadius": "6378", "electric": "8.854187e-12", "electronMass": "9.10938291e-31", "elementaryCharge": "1.602176565e-19", "EulerGamma": "0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495146314472498070824809605040144865428362241739976449235362535003337429373377376739427925952582470949160087352039481656708532331517766115286211995015080", "Faraday": "96485.3365", "fineStructure": "7.2973525698e-3", "goldenRatio": "1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752126633862223536931793180060766726354433389086595939582905638322661319928290267880675208766892501711696207032221043216269548626296", "gravity": "9.80665", "inverseFineStructure": "137.035999074", "magnetic": "12.566370614e-7", "magneticFluxQuantum": "2.067833758e-15", "molarGas": "8.3144621", "moonMass": "7.348e22", "moonRadius": "1738", "neutronMass": "1.674927351e-27", "NewtonGravitation": "6.67384e-11", "pi": "3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909", "Planck": "6.62606957e-34", "proton-electronMassRatio": "1836.15267245", "proton-neutronMassRatio": "0.99862347826", "protonMass": "1.672621777e-27", "Rydberg": "10973731.568539", "speedOfLight": "299792458", "speedOfSound": "340.27", "sqrt(2)": "1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641572735013846230912297024924836055850737212644121497099935831413222665927505592755799950501152782060571470109559971605970274534596862014728517418640889199", "Stefan-Boltzmann": "5.670373e-8", "sunMass": "1.989e30", "sunRadius": "695500", "TheRockMass": "124.73790175", "ThomsonCrossSection": "0.6652458734e-28", "UltimateAnswer": "42", "zeroKelvin": "-273.15" } const BN = BigNumber.clone({ DECIMAL_PLACES: n }) const num = numbers[name].split("e") if (num.length > 1) { return new BN(`${num[0].slice(0, n + 2)}e${num[1]}`) } return new BN(num[0].slice(0, n + 2)) }