Skip to content

Commit

Permalink
added format
Browse files Browse the repository at this point in the history
  • Loading branch information
xShadowBlade authored Oct 11, 2023
1 parent 8d49673 commit 4ace190
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
27 changes: 25 additions & 2 deletions website/docs/eMath/E/e.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ The ``E`` function is the main feature of this package. It is based on [break_et
Assuming that you already followed the instructions in the [usage guide](../../usage), you can use it as:
```js
const { E } = eMath;
const newNum2 = E(2300) // Number with value 2300
console.log(newNum2.format()) // "2,300"

const newNum2 = E(2300); // Number with value 2300
newNum2; // 2300
```

The methods and functions are the same as breaK_eternity.js, which are the same as [Decimal.js](https://github.com/MikeMcl/decimal.js). For example,

```js
const { E } = eMath;

const x = E(123.4567);
const y = E('123456.7e-3');
const z = E(x);
x.equals(y) && y.equals(z) && x.equals(z); // true
```

To call methods, you can call ``E[method]``. For example,

```js
const { E } = eMath;

const x = E(63);
const y = E(7);

E.divide(x, y); // E(9)
```
47 changes: 47 additions & 0 deletions website/docs/eMath/E/format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
id: format
title: Format
---

---

The ``E.format()`` function is the main way to convert ``E`` to a ``string``.

### Usage

After you create a new ``E``, you can call the ``format()`` method.
```js
const { E } = eMath;

const newNum = E(2300); // Number with value 2300
newNum.format(); // "2,300"
```

Alternatively, you can use the static ``E.format()`` method.
```js
const { E } = eMath;

const newNum2 = E(2000); // Number with value 2000
E.format(newNum2); // "2,300"
```

### Outputs

After you reach 1,000,000,000 (1 billion), the format is automatically converted into letter form.

```js
const { E } = eMath;

const newNum3 = E(1.23e9); // Number with value 1.23 billion
E.format(newNum2); // "1.23 B"
```

After you reach 1e+300 (1 novemnonagintillion), the format is automatically converted into scientific form.

```js
const { E } = eMath;

const newNum3 = E(1.32e303); // Number with value 1.23 billion
E.format(newNum2); // "1.32e303"
```

1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const sidebars = {
label: "E",
items: [
"eMath/E/E",
"eMath/E/format"
],
},
{
Expand Down

0 comments on commit 4ace190

Please sign in to comment.