-
Notifications
You must be signed in to change notification settings - Fork 121
Closed
Labels
T-UserTag user issues / requestsTag user issues / requests[C] Feature / EnhancementA new feature request or enhancement to an existing feature.A new feature request or enhancement to an existing feature.
Description
Requested feature: in_range to check if a float is in the range of the targeting integer type, e.g.
kani::in_range(IntType, floatType, float) or something similar
Example: f32::to_int_unchecked contract
#[requires(self.is_finite() && kani::in_range(Int, Self, self))]
pub unsafe fn to_int_unchecked<Int>(self) -> Int where Self: FloatToInt<Int> {...}
Thank you for sharing this. Is it possible to have Kani support this? E.g. expose an
in_range(float, floatType, IntType)
API that we can directly call. We saw that the Kani internally has codegen_in_range_expr which we think useful.
Thank you! @zhassan-awsYes, I think it would be possible. This would likely need to be done through providing a trait and its implementation for different float types so that it can be used with the generic
Int
. Can you file a feature request in the Kani repo?
Metadata
Metadata
Assignees
Labels
T-UserTag user issues / requestsTag user issues / requests[C] Feature / EnhancementA new feature request or enhancement to an existing feature.A new feature request or enhancement to an existing feature.