对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

$sinh(表达式操作符)

$sinh

返回以弧度为单位来测量的某一值的双曲正弦值。

$sinh 通过以下语法实现:

{ $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.

默认下,$sinh 128$sinh返回double<expression> 128形式的值。如果 解析为 位十进制值, 还可以返回 位十进制值。

有关表达式的更多信息,请参阅表达式

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.

例子
结果

{ $sinh: NaN }

NaN

{ $sinh: null }

null

{ $sinh: -Infinity }

-Infinity

{ $sinh: Infinity }

Infinity

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")
}

由于angle 128存储为$sinh 位十进制数,因此 输出也是128 位十进制数。

以下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.

给本页内容打分

在此页面上