antimatter-dimensions / notations Goto Github PK
View Code? Open in Web Editor NEWAntimatter Dimensions notations
License: MIT License
Antimatter Dimensions notations
License: MIT License
Unit tests can be used to verify that everything works as intended.
This mostly consists of binary logarithm and other-base notations where numbers are still shown in base 10.
Can you add an option to remove spaces from Standard and Mixed Scientific?
For example, instead of 10.00 B
, I would like it to be formatted as 10.00B
anything that starts with "e" or has a decimal number in the exponent (after an e) will break when the parser reaches prime notation.
I think this relates to
name: Merge Dependabot PR
on:
pull_request:
branches:
- master
jobs:
merge-me:
name: Merge Dependabot PR
runs-on: ubuntu-latest
steps:
- name: Merge Dependabot PR
uses: ridedott/merge-me-action@master
with:
GITHUB_LOGIN: dependabot[bot]
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
and ridedott/merge-me-action#814 (saying "this method of using ridedott/merge-me-action broke") and https://github.com/ridedott/merge-me-action#usage (how to use ridedott/merge-me-action now). In other words, we're using ridedott/merge-me-action, the way in which we were doing it broke, and we can probably fix it by using a different syntax.
However, I don't understand enough about JS ecosystem to know exactly which new syntax to use. We're a public repository so we probably want to use the public repository advice, which seems like we want to switch to something like:
on:
workflow_run:
types:
- completed
workflows:
# List all required workflow names here.
- 'Continuous Integration'
rather than pull request, and also switch to v2. However, something seems pretty suspicious here and I'd probably want to do more research (why v2 instead of master?). Also, IDK if our workflow is called "Continuous Integration".
E.g, 1.00000000001, which is 1 + 1e-11, is displayed as C0000000 (the same as 1), when in fact it should be displayed as (I believe) C1CDAF2C. This is caused by (new ADNotations.HexNotation()).modifiedLogarithm(new Decimal(1.00000000001))
being 0 (when it should be 1e-11). This is in turn caused by line 57 of src/hex.js, in the course of calculating the modified logarithm of new Decimal(1.00000000001),
taking (new Decimal(1.00000000001)).toNumber()
, which is 1 rather than, as might be expected, 1.00000000001. This is caused by the .toNumber
method on Decimals doing rounding when the input is sufficiently close to an integer.
This rounding being desirable behavior for the .toNumber
method in most cases, and numbers such as 1.00000000001
rarely if ever occurring in most likely use-cases of this library, this, though it's a bug, likely won't be fixed. Furthermore, as can be seen in the code of break_infinity.js (a comment starting on line 680 of src/break_infinity.ts as of this issue being created), writing a version of .toNumber such that new Decimal(x).toNumber()
is an integer if and only if x
is an integer for, say, all x
between 0 and 1000, is surprisingly hard. Also, even if a number like 1.00000000001
does occur, it's reasonably likely that it is a misrounded version of 1 and showing it as C0000000 is the right thing to do. If there's enough outcry about this not being fixed, I might try to fix it anyway, though.
The current implementation of fixMantissaOverflow
seems to always round up (when the first non-significant digit is 5), as noted on
notations/spec/infix/infix-eng.spec.js
Lines 14 to 15 in 3799032
I think it'd be better to implement the "round half to even" algorithm (see also the IEEE754 stuff about rounding).
In a nutshell:
A tie-breaking rule without positive/negative bias and without bias toward/away from zero is round half to even. By this convention, if the fractional part of x is 0.5, then y is the even integer nearest to x. Thus, for example, +23.5 becomes +24, as does +24.5; while −23.5 becomes −24, as does −24.5. This function minimizes the expected error when summing over rounded figures, even when the inputs are mostly positive or mostly negative.
Currently, imperial doesn’t display values correctly past a certain point (around 1e6.7e11). Hence, some adjectives need to be added.
Suggestions:
‘Microscopic’ - before minute
‘Meager’ - between small and modest
‘Abundant’ - between large and great
‘Expansive’ - between large and great (after abundant?)
‘Grand’ - between great and huge
‘Immense’ - between gigantic and colossal
‘Endless’ - after cosmic
Inputting a negative number into the input box on the demo page results in a freeze. (I think this might be related to prime notation?)
This appears to be called by ad-notations.min.js trying to use tslib, which it can't because tslib is not defined.
Is your feature request related to a problem? Please describe.
Some examples: 1e1.5e12 => 1e2e12
1e7.4e13 => 1e7e13
Describe the solution you'd like
Rounding of Y in XeYeZ should be at least 2 dp, or have an additional parameter that specifies the precision.
This is (I believe) due to formatUnder1000 being called and the Decimals being converted to number. It's only apparent for hex notation; on the demos page, 1e-324 isn't formatted as 80000000, but 1e-325 is formatted as 80000000. However, (new ADNotations.HexNotation()).formatDecimal(new Decimal('1e-325'))
isn't 80000000. (It seems to me that in scientific notation, sufficiently small numbers should perhaps be formatted with negative exponents, contrary to what currently appears to be the case; however, that should probably be a separate issue.)
I don't want to try to fix this until I know whether it's considered important enough to fix and whether other notations that can use negative exponents (mostly scientific and its close relatives, but also logarithm and arguably brackets and roman) should also format small numbers differently.
Lines 59 to 63 in ca22e02
First, this is wrong- it will produce "factorizations" that are not equal to the original number. Second, 10k is ridiculously low! You hardly ever see numbers that low in antimatter dimension.
I realize that this is intended to be a shorthand, so 10007 is written "(2²×5²)^(2)" in prime notation for the same reason that it is written "1.00e4" in scientific. I also realize that integer factorization is in NP and that you have to cut corners at some point in favor of gameplay.
However, incorrect factorizations that doesn't even share any factors with the original number is borderline offensive! Can we do better?
The non-community notations are all meant to be high-quality and correctly implemented, yet they still sometimes have bugs or other surprising behavior. They should all have thorough testing done on them in the test suite to check that they work.
I'd like to have notations using the prefixes from the international system of units, i.e.:
k M G T P E Z Y R Q B
Or their long forms:
Kilo Mega Giga Tera Peta Exa Zetta Yotta Ronna Quecca Bundecca
Note that I'm including the proposal for Ronna and Quecca, as well as the hypothetical Bundecca.
I guess that a nice approach would be to add this as a setting, and letting the abbreviate
function use either the "standard" list (K M B T Qa Qt Sx Sp Oc No Dc, etc), the "short SI" list (k M G T P E Z Y R Q B) or the "long SI" list (Kilo Mega Giga Tera Peta Exa Zetta Yotta Ronna Quecca Bundecca). I don't see a need to add whole new notations, but rather change how the ones using the "standard" suffixes work.
There's also a proposal to extend the SI prefixes up to 10^48, which boils down to
k M G T P E Z Y kY MY GY TY PY EY ZY YY
Arguably this could be extended like...
k M G T P E Z Y R Q B kB MB GB TB PB EB ZB YB RB QB BB kBB MBB GBB TBB PBB EBB ZBB YBB RBB QBB BBB kBBB
...and later, add an exponent to the Bundeccas (to support those insane 1e9999999999
numbers), like
MB² = MBB
MB³ = MBBB
MB⁴ = MBBBB
You could either keep it centered and have a header for community ones, or you could separate them into different columns.
1eeeee1 = 1
1eeeeee1 = 10
etc.
Steps to reproduce:
npm init
npm i @antimatter-dimensions/notations break_infinity.js
installed Packages:
Test Script:
const Decimal = require("break_infinity.js");
const ADNotations = require("@antimatter-dimensions/notations")
const notation = new ADNotations.StandardNotation();
console.log(notation.formatDecimal(new Decimal(1)));
Trace (.\ is project root):
TypeError: t.indexOf is not a function
at t.fromString (.\node_modules\break_infinity.js\dist\break_infinity.common.js:1:6465)
at new t (.\node_modules\break_infinity.js\dist\break_infinity.common.js:1:743)
at i (.\node_modules\break_infinity.js\dist\break_infinity.common.js:1:243)
at t.div (.\node_modules\break_infinity.js\dist\break_infinity.common.js:1:10392)
at .\node_modules\@antimatter-dimensions\notations\dist\ad-notations.umd.js:106:24
at StandardNotation.formatDecimal (.\node_modules\@antimatter-dimensions\notations\dist\ad-notations.umd.js:413:110)
at Object.<anonymous> (.\index.js:6:22)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.