adnot-beport-small
v1.2.1
Published
Notations used in Antimatter Dimensions, built for break_eternity.js. This set of notations is specifically built for numbers less than 1e9e15
Downloads
166
Readme
Antimatter Dimensions Notations - break_eternity.js Port
All the notations that are included in the current version of Antimatter Dimensions, and the upcoming Reality Update, however they have been ported to break_eternity.js
Setup
CDN
The simplest way to use this package is to include these scripts in your HTML page:
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/break_eternity.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/adnot-beport-small"></script>
You can also grab specific versions here:
- https://github.com/Patashu/break_eternity.js/releases
- https://github.com/HexaVault/BEnotations-Pre
All the notations are included inside ADNotations
object:
const scientific = new ADNotations.ScientificNotation();
The main method that notations provide is format(value, places, placesUnder1000)
value
can beDecimal
,number
orstring
which you want to formatplaces
is used to format mantissa when number is greater than 1000placesUnder1000
is used to format the number when it is lesser than 1000
const scientific = new ADNotations.ScientificNotation();
// Outputs "1000.00"
console.log(scientific.format(1000, 2, 2));
// Outputs "1.00e100"
console.log(scientific.format("1e100", 2, 0));
// Outputs "1e100"
console.log(scientific.format(new Decimal(1e100), 0, 0));
You can configure some formatting aspects via ADNotations.Settings
object:
const scientific = new ADNotations.ScientificNotation();
// Outputs "1e100,000"
console.log(scientific.format("1e100000", 2, 2));
// Outputs "1e100000"
ADNotations.Settings.exponentCommas.show = false;
console.log(scientific.format("1e100000", 2, 2));
// Outputs "Infinite"
ADNotations.Settings.isInfinite = decimal => decimal.gte(1e100);
console.log(scientific.format(1e101, 2, 2));
Configuration settings:
Settings.isInfinite
- function that determines if aDecimal
value is infinite (default isdecimal => decimal.gte(Decimal.MAX_VALUE)
)Settings.exponentCommas.show
- show commas in formatted output (default is true)Settings.exponentCommas.min
- lower bound for exponent to be formatted with commas (default is 100000)Settings.exponentCommas.max
- upper bound for exponent to be formatted with commas (default is 1000000000)
Extend
Creating your own notations is very simple! Just extend base class Notation
and implement the required methods get name()
and formatDecimal
:
class SimpleNotation extends ADNotations.Notation {
get name() {
return "Simple";
}
formatDecimal(value, places) {
return `Mantissa: ${value.mantissa.toFixed(places)}, Exponent: ${value.exponent}`;
}
}
You can also extend existing notations (like EmojiNotation
does) and override
other methods, but this is a more advanced case which you can figure out by
looking at the source code of existing notations.
Community Notations
To use community notations, download community pack from the releases page. The community pack can be used separately from the base pack.
If you want your notation to be publicly available via this library, you should
start by adding your notation to a src/community
folder and making a pull
request with it.
After your PR is merged (which means that one of the maintainers decided that it is good enough), you can reach out to AD devs about adding it to a base game. There is no guarantee that it will be added, but all well-made notations will be available as a community pack.
Acknowledgements
Special thanks to the authors of notations:
- Scientific: iblobtouch
- Engineering: iblobtouch
- Letters: iblobtouch
- Standard: Slabdrill
- Emoji: haha hevi screw u 😂😂😂
- Mixed Scientific: Hevipelle
- Mixed Engineering: Hevipelle
- Logarithm: Hevipelle
- Brackets: Boo
- Infinity: Omsi
- Roman: Razenpok
- Dots: Garnet
- Zalgo: SpectralFlame
- Hex: dan-simon
- Imperial: Garnet, realrapidjazz
- Clock: Razenpok, Garnet
- Prime: Iker
- Bar: Earth
- Shi: dan-simon
- Blind: Earth
- ALL: SpectralFlame
Thanks to the authors of community notations:
- Greek Letters: cook1ee
- Omega: cook1ee
- Omega (Short): cook1ee
- Precise Prime: Based on Prime by Iker, idea by BlackCapCoder, changes to Prime mostly by dan-simon
- Japanese: Chiyozel
- Mixed Logarithm (Sci): Chiyozel
- Tritetrated: dan-simon
- Flags: Kajfik
- YesNo: Kaedenn
- Evil: dan-simon
- Emojier: dan-simon
- Chinese: ducdat0507
- Binary: Suggested by Garnet, implemented by dan-simon
- Hexadecimal: Suggested by Garnet, implemented by dan-simon, independently created earlier by Aarex
- Haha Funny: Earth
- Nice: Earth
- Long scale: Ivan Sanchez
- Infix engineering: Ivan Sanchez
- Reverse infix engineering: Ivan Sanchez
- Infix standard: Ivan Sanchez
- Infix long scale: Ivan Sanchez
- English: ducdat0507
And a thanks to the base notations code. You can find it here, however it is intended for use with break_infinity.