Skip to content

Commit cbb6688

Browse files
committed
Minor documentation changes. Bump version to 0.1.2.
1 parent cc5436f commit cbb6688

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

Decimal.ts

+16-11
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default class Decimal {
4545

4646
/**
4747
* Rounds the current value up towards positive infinity to the nearest multiple of the specified precision.
48-
* @param precision The optional precision to round to. Defaults to `Decimal.one`, meaning it rounds to the nearest integer.
48+
* @param precision The precision to round to. Defaults to `Decimal.one`, meaning it rounds to the nearest integer.
4949
* @returns A new Decimal instance representing the rounded value.
5050
*/
5151
ceil(precision: DecimalType = Decimal.one): Decimal {
@@ -68,9 +68,9 @@ export default class Decimal {
6868
/**
6969
* Divides the current Decimal instance by the provided value.
7070
* Throws if the resulting value cannot be represented with a fixed number of decimals (like 1/3).
71-
* If you need to divide by such a value, use the optional `significantDigits` parameter to specify the number of significant digits.
71+
* If you need to divide by such a value, use the optional `significantDigits` parameter to specify the number of significant digits to use in the result.
7272
* @param value The value to divide by.
73-
* @param significantDigits The optional number of significant digits to use in the result.
73+
* @param significantDigits The number of significant digits to use in the result.
7474
* @returns A new Decimal instance representing the result of the division.
7575
*/
7676
div(value: DecimalType, significantDigits?: number): Decimal {
@@ -142,7 +142,7 @@ export default class Decimal {
142142

143143
/**
144144
* Rounds the current value down towards negative infinity to the nearest multiple of the specified precision.
145-
* @param precision The optional precision to round to. Defaults to `Decimal.one`, meaning it rounds to the nearest integer.
145+
* @param precision The precision to round to. Defaults to `Decimal.one`, meaning it rounds to the nearest integer.
146146
* @returns A new Decimal instance representing the rounded value.
147147
*/
148148
floor(precision: DecimalType = Decimal.one): Decimal {
@@ -193,9 +193,15 @@ export default class Decimal {
193193

194194
/**
195195
* Returns the multiplicative inverse of the current Decimal instance.
196+
*
196197
* Throws if the resulting value cannot be represented with a fixed number of decimals (like 1/3).
197-
* If you need to invert such a value, use the optional `significantDigits` parameter to specify the number of significant digits.
198-
* @param significantDigits The optional number of significant digits to use in the result.
198+
* If you need to invert such a value, use the optional `significantDigits` parameter to specify the number of significant digits to use in the result.
199+
*
200+
* ```ts
201+
* Decimal.from(3).inv(); // Throws
202+
* Decimal.from(3).inv(2); // Returns 0.33
203+
* ```
204+
* @param significantDigits The number of significant digits to use in the result.
199205
* @returns A new Decimal instance representing the inverse.
200206
*/
201207
inv(significantDigits?: number): Decimal {
@@ -340,7 +346,7 @@ export default class Decimal {
340346
/**
341347
* Rounds the current value towards the nearest multiple of the specified precision.
342348
* If the current value is exactly halfway between two multiples of the precision, it is rounded up towards positive infinity.
343-
* @param precision The optional precision to round to. Defaults to `Decimal.one`, meaning it rounds to the nearest integer.
349+
* @param precision The precision to round to. Defaults to `Decimal.one`, meaning it rounds to the nearest integer.
344350
* @returns A new Decimal instance representing the rounded value.
345351
*/
346352
round(precision: DecimalType = Decimal.one): Decimal {
@@ -374,7 +380,7 @@ export default class Decimal {
374380

375381
/**
376382
* Converts the current Decimal instance to a bigint, if it is an integer.
377-
* @throws Will throw an error if the Decimal instance is not an integer.
383+
* Throws an error if the Decimal instance is not an integer.
378384
* @returns A bigint representing the integer value of the Decimal instance.
379385
*/
380386
toBigInt(): bigint {
@@ -481,10 +487,10 @@ export default class Decimal {
481487
/**
482488
* Divides one value by another.
483489
* Throws if the resulting value cannot be represented with a fixed number of decimals (like 1/3).
484-
* If you need to divide by such a value, use the optional `significantDigits` parameter to specify the number of significant digits.
490+
* If you need to divide by such a value, use the optional `significantDigits` parameter to specify the number of significant digits to use in the result.
485491
* @param dividend The value to divide.
486492
* @param divisor The value to divide by.
487-
* @param significantDigits The optional number of significant digits in the result.
493+
* @param significantDigits The number of significant digits to use in the result.
488494
* @returns A new Decimal instance representing the quotient.
489495
*/
490496
static div(dividend: DecimalType, divisor: DecimalType, significantDigits?: number): Decimal {
@@ -516,7 +522,6 @@ export default class Decimal {
516522
* @param numerator The numerator of the fraction.
517523
* @param denominator The denominator of the fraction.
518524
* @returns A Decimal instance representing the fraction.
519-
* @throws Will throw an error if the fraction cannot be represented with a fixed number of decimals.
520525
*/
521526
static fromFraction({ numerator, denominator }: { numerator: bigint; denominator: bigint }): Decimal {
522527
if (denominator < 0n) {

deno.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@quentinadam/decimal",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"exports": "./Decimal.ts",
55
"imports": {
66
"@quentinadam/assert": "jsr:@quentinadam/assert@^0.1.6"

0 commit comments

Comments
 (0)