> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/zh/code/builtin/data-transformation-functions/numbers.md).

# Duaer 数字上的转换方法

在 Duaer 表达式里，数字方法做取整、奇偶判断，以及转成布尔、字符串或 DateTime。round 取最接近的数，ceil 向上，floor 向下。
## 方法

- abs()：绝对值。
- ceil()：向上取整。floor()：向下取整。round(小数位?)：取最接近的数。
- isEven()、isOdd()、isInteger()：偶数、奇数、整数。
- isEmpty()、isNotEmpty()：空或不空。
- format(样式)：按给定样式变成字符串。toLocaleString()：按当前语言格式化。toString()：普通字符串。
- toBoolean()：0 是 false，其他数字是 true。
- toDateTime()：当成时间戳转成 DateTime。单位要和你存的毫秒或秒一致，转完用日期那一页的方法格式化。

```
{{ $json.amount.round(2) }}
```
## Questions

### 在 Duaer 里 round、ceil、floor 有什么区别？

在 Duaer 表达式里，round() 取最接近的数，可以带小数位数。ceil() 向上取整。floor() 向下取整。abs() 是绝对值。

### Duaer 的 toBoolean 怎么判断数字？

在 Duaer 表达式里，0 变成 false，其他数字变成 true。

