-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overflow Int in Repeater.Interval.Internal.second #48
Comments
My proposal of solving this issue: extension Repeater.Interval {
/// safeSeconds fix issue with int range overflow in Repeater.Interval.Interval.Seconds.
/// It should be used instead of Repeater.Interval.Interval.Seconds
static func safeSeconds(_ seconds: Double) -> Self {
/// Repeater uses milliseconds as basic unit. It converts seconds to milliseconds
let secondsInMiliseconds = Double(seconds) * Double(1000)
/// check if seconds expressed in miliseconds overflows int range
if secondsInMiliseconds.isInIntRange {
return .seconds(seconds)
} else {
let overflowValue = seconds >= 0 ? Int.max : Int.min
return .milliseconds(overflowValue)
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On iPhone 5 with 32 bits processor it is possible to make int overflow. The underlay seconds:
which can exceeding the scope of int
The text was updated successfully, but these errors were encountered: