On this page本页内容
$sinh
New in version 4.2.在版本4.2中新增。
Returns the hyperbolic sine of a value that is measured in radians.返回以弧度度量的值的双曲正弦值。
$sinh has the following syntax:语法如下:
{ $sinh: <expression> }
$sinh takes any valid expression that resolves to a number, measured in radians. 接受解析为数字(以弧度为单位)的任何有效表达式。If the expression returns a value in degrees, use the 如果表达式返回以度为单位的值,请使用$degreesToRadians operator to convert the value to radians.$degreesToRadians运算符将该值转换为弧度。
By default 默认情况下,$sinh returns values as a double. $sinh以double形式返回值。如果$sinh can also return values as a 128-bit decimal if the <expression> resolves to a 128-bit decimal value.<expression>解析为128位十进制值,$sinh也可以将值返回为128位十进制。
For more information on expressions, see Expressions.有关表达式的详细信息,请参阅表达式。
null, NaN, and +/- InfinityIf the input argument resolves to a value of 如果输入参数解析为null or refers to a field that is missing, $sinh returns null. null值或引用缺少的字段,$sinh将返回null。If the argument resolves to 如果参数解析为NaN,NaN, $sinh returns NaN. $sinh将返回NaN。If the argument resolves to negative or positive 如果参数解析为负Infinity, $sinh returns negative or positive Infinity respectively.Infinity或正Infinity,$sinh将分别返回负Infinity和正Infinity。
{ $sinh: NaN } | NaN |
{ $sinh: null } | null |
{ $sinh: -Infinity } | -Infinity |
{ $sinh: Infinity } | Infinity |
The following 以下trigonometry collection contains a document that stores an angle value measured in degrees:trigonometry集合包含一个文档,该文档存储以度为单位的angle值:
db.trigonometry.insertOne( { "_id" : ObjectId( "5c50782193f833234ba90d25" ), "angle" : NumberDecimal( "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:$sinh表达式计算双曲正弦角度,并使用$addFields管道阶段将其添加到输入文档中:
db.trigonometry.aggregate( [ { $addFields : { "sinh_output" : { $sinh : { $degreesToRadians : "$angle" } } } } ] )
The $degreesToRadians expression converts the angle in degrees to radians.$degreesToRadians表达式将angle(以度为单位)转换为弧度。
Example output:输出示例:
{
"_id" : ObjectId("5c50782193f833234ba90d25"),
"angle" : NumberDecimal("53.1301023541559787031443874490659"),
"sinh_output" : NumberDecimal("1.066020404405732132503284522731829")
}Because 因为angle is stored as a 128-bit decimal, the $sinh output is also a 128-bit decimal.angle存储为128位十进制,所以$sinh输出也是128位十进制。
The following 以下trigonometry collection contains a document that stores an angle value measured in radians:trigonometry集合包含一个文档,该文档存储以angle度量的角度值:
db.trigonometry.insertOne( { "_id" : ObjectId( "5c50782193f833234ba90d35" ), "angle" : NumberDecimal( "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:$sinh表达式计算双曲正弦角度,并使用$addFields管道阶段将其添加到输入文档中:
db.trigonometry.aggregate( [ { $addFields : { "sinh_output" : { $sinh : "$angle" } } } ] )
Example output:输出示例:
{
"_id" : ObjectId("5c50782193f833234ba90d35"),
"angle" : NumberDecimal("1.6301023541559787031443874490659"),
"sinh_output" : NumberDecimal("2.454243813557362033961729701069671")
}Because angle is stored as a 128-bit decimal, the $sinh output is also
a 128-bit decimal.