github / github/codeql

Document CodeQL `float` `floor()` and `ceil()` behavior for values outside of `int` range

Đang mở
#13,063 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
question
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

The documentation for the CodeQL predicates `float.floor()` and `float.ceil()` says:
> Returns the largest integer that is not greater than the receiver

> Returns the smallest integer greater than or equal to the receiver

For both the documentation is incorrect for results outside the `int` value range. The actual behavior of these predicates is that they use the minimum / maximum `int` value if the value exceeds the `int` value range, as seen with this query:
```codeql
from float f
where f = [2200000000.0, -2200000000.0]
select f, f.floor() as floor, f.ceil() as ceil
```

The results are:
| f | floor | ceil |
| -- | -- | -- |
| -2200000000 | -2147483648 | -2147483648
| 2200000000 | 2147483647 | 2147483647

(Tested with CodeQL CLI 2.13.1)

It would be good if the documentation for `floor()` and `ceil()` is adjusted to explicitly mention this.

This might also have to be adjusted in the [QL language specification](https://codeql.github.com/docs/ql-language-reference/ql-language-specification/#built-ins-for-float).

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.