Skip to content

Commit 73a69a6

Browse files
committed
Feat: add euler's constant
1 parent e0165b2 commit 73a69a6

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/constants.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Interval } from './interval'
2+
import round from './round'
23

34
const piLow = (3373259426.0 + 273688.0 / (1 << 21)) / (1 << 30)
45
const piHigh = (3373259426.0 + 273689.0 / (1 << 21)) / (1 << 30)
@@ -32,6 +33,25 @@ const constants = {
3233
* @static
3334
* @example
3435
* ```typescript
36+
* Interval.E
37+
* ```
38+
* @name E
39+
* @type {Interval}
40+
*/
41+
get E(): Interval {
42+
return new Interval(
43+
round.prev(Math.E),
44+
round.next(Math.E)
45+
)
46+
},
47+
48+
/**
49+
* An interval that represents Euler's constant e, NOTE: calls to Interval.E always return
50+
* a new interval representing PI
51+
* @memberof constants
52+
* @static
53+
* @example
54+
* ```typescript
3555
* Interval(Interval.PI_LOW, Interval.PI_HIGH)
3656
* ```
3757
* @name PI

src/interval.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ describe('interval', function () {
7979
assert(x.lo < x.hi)
8080
assertEps(x.lo, Math.PI)
8181
assertEps(x.hi, Math.PI)
82+
x = Interval.E
83+
assert(x.lo < x.hi)
84+
assertEps(x.lo, Math.E)
85+
assertEps(x.hi, Math.E)
8286
})
8387

8488
it('should check NaN on assignment', function () {

0 commit comments

Comments
 (0)