Docs Menu

$exp (aggregation)

이 페이지의 내용

$exp

Raises Euler's number (i.e. e ) to the specified exponent and returns the result.

$exp의 구문은 다음과 같습니다.

{ $exp: <exponent> }

<exponent> 표현식은 숫자로 해석되는 한 유효한 표현식 일 수 있습니다. 표현식에 대한 자세한 내용은 표현식 연산자를 참조하세요.

기본 반환 유형은 double입니다. 피연산자 중 하나라도 decimal이면 반환 유형은 10진수입니다.

인수가 null 값으로 해석되거나 누락된 필드를 참조하는 경우 $expnull을 반환합니다. 인수가 NaN으로 해석되는 경우, $expNaN을 반환합니다.

예시
결과

{ $exp: 0 }

1

{ $exp: 2 }

7.38905609893065

{ $exp: -2 }

0.1353352832366127

accounts라는 이름의 컬렉션에 다음 문서가 포함되어 있습니다.

db.accounts.insertMany( [
{ _id: 1, interestRate: .08, presentValue: 10000 },
{ _id: 2, interestRate: .0825, presentValue: 250000 },
{ _id: 3, interestRate: .0425, presentValue: 1000 }
] )

The following example calculates the effective interest rate for continuous compounding:

db.accounts.aggregate( [ { $project: { effectiveRate: { $subtract: [ { $exp: "$interestRate"}, 1 ] } } } ] )

이 연산은 다음과 같은 결과를 반환합니다.

{ "_id" : 1, "effectiveRate" : 0.08328706767495864 }
{ "_id" : 2, "effectiveRate" : 0.08599867343905654 }
{ "_id" : 3, "effectiveRate" : 0.04341605637367807 }

이 페이지의 내용