“文档” 菜单
文档首页
/
MongoDB Manual
/ / /

$tan(聚合)

在此页面上

  • 行为
  • 例子
$tan

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

$tan 通过以下语法实现:

{ $tan: <expression> }

$tan接受解析为数字的任何有效表达式。如果表达式返回以度为单位的值,请使用$degreesToRadians操作符将结果转换为弧度。

默认情况下,$tan 会以 double 的形式返回值。只要 <expression> 解析为 128 位十进制值, $tan 也会返回 128 位十进制值

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

如果参数解析为 null 值或引用了缺失的字段,则 $tan 返回 null。如果参数解析为 NaN,则 $tan 返回 NaN。如果参数解析为负无穷大或正无穷大,$tan 将抛出错误。

例子
结果
{ $tan: NaN }
NaN
{ $tan: null }
null

{ $tan : Infinity}

或是

{ $tan : -Infinity }

抛出一条类似以下格式化输出的错误消息:

"errmsg" :
"Failed to optimize pipeline :: caused by :: cannot
apply $tan to -inf, value must in (-inf,inf)"
← $switch(聚合)

在此页面上