$sinh返回以弧度为单位来测量的某一值的双曲正弦值。
$sinh通过以下语法实现:{ $sinh: <expression> } $sinhtakes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the$degreesToRadiansoperator to convert the value to radians.默认下,
$sinh128$sinh返回double<expression>128形式的值。如果 解析为 位十进制值, 还可以返回 位十进制值。有关表达式的更多信息,请参阅表达式。
行为
null、NaN 和+/- Infinity
If the input argument resolves to a value of null or refers to a field that is missing, $sinh returns null. If the argument resolves to NaN, $sinh returns NaN. If the argument resolves to negative or positive Infinity, $sinh returns negative or positive Infinity respectively.
例子 | 结果 |
|---|---|
|
|
|
|
|
|
|
|
例子
trigonometry以下collection包含一个文档,其中存储了一个以度数为单位的angle 值:
db.trigonometry.insertOne( { "_id" : ObjectId( "5c50782193f833234ba90d25" ), "angle" : Decimal128( "53.1301023541559787031443874490659" ) } )
The following aggregation operation uses the $sinh expression to calculate the hyperbolic sine of angle and adds it to the input document using the $addFields pipeline stage:
db.trigonometry.aggregate( [ { $addFields : { "sinh_output" : { $sinh : { $degreesToRadians : "$angle" } } } } ] )
$degreesToRadians表达式将以度为单位的angle转换为弧度。
示例输出:
{ "_id" : ObjectId("5c50782193f833234ba90d25"), "angle" : Decimal128("53.1301023541559787031443874490659"), "sinh_output" : Decimal128("1.066020404405732132503284522731829") }
以下trigonometry集合包含一个文档,其中存储了以弧度为单位的angle值:
db.trigonometry.insertOne( { "_id" : ObjectId( "5c50782193f833234ba90d35" ), "angle" : Decimal128( "1.6301023541559787031443874490659" ) } )
The following aggregation operation uses the $sinh expression to calculate the hyperbolic sine of angle and adds it to the input document using the $addFields pipeline stage:
db.trigonometry.aggregate( [ { $addFields : { "sinh_output" : { $sinh : "$angle" } } } ] )
示例输出:
{ "_id" : ObjectId("5c50782193f833234ba90d35"), "angle" : Decimal128("1.6301023541559787031443874490659"), "sinh_output" : Decimal128("2.454243813557362033961729701069671") }
Because angle is stored as a 128-bit decimal, the $sinh output is also a 128-bit decimal.