-
Notifications
You must be signed in to change notification settings - Fork 939
GUI: replace sta::Delay with float for numeric_limits #10066
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -678,7 +678,7 @@ int ClockTree::getMaxLeaves(bool visibility = false) const | |||||
|
|
||||||
| sta::Delay ClockTree::getMinimumArrival(bool visibility = false) const | ||||||
| { | ||||||
| sta::Delay minimum = std::numeric_limits<sta::Delay>::max(); | ||||||
| sta::Delay minimum = std::numeric_limits<float>::max(); | ||||||
| if (!visibility or isVisible()) { | ||||||
| for (const auto& [driver, arrival] : drivers_) { | ||||||
| minimum = std::min(minimum, arrival); | ||||||
|
|
@@ -700,7 +700,7 @@ sta::Delay ClockTree::getMinimumArrival(bool visibility = false) const | |||||
|
|
||||||
| sta::Delay ClockTree::getMaximumArrival(bool visibility = false) const | ||||||
| { | ||||||
| sta::Delay maximum = std::numeric_limits<sta::Delay>::min(); | ||||||
| sta::Delay maximum = std::numeric_limits<float>::min(); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using std::numeric_limits::min() here is a logic error. In C++, std::numeric_limits::min() for floating-point types returns the smallest positive normalized value (approximately 1.17e-38), not the most negative value. If all arrival times are 0.0, std::max(maximum, arrival) will compare 1.17e-38 with 0.0 and keep 1.17e-38, leading to an incorrect result. To initialize a maximum search, you should use a value that is guaranteed to be less than or equal to any possible value, such as -sta::INF or std::numeric_limits::lowest(). Given the existing code style, -sta::INF is the preferred choice.
Suggested change
References
|
||||||
| if (!visibility or isVisible()) { | ||||||
| for (const auto& [driver, arrival] : drivers_) { | ||||||
| maximum = std::max(maximum, arrival); | ||||||
|
|
@@ -722,7 +722,7 @@ sta::Delay ClockTree::getMaximumArrival(bool visibility = false) const | |||||
|
|
||||||
| sta::Delay ClockTree::getMinimumDriverDelay(bool visibility = false) const | ||||||
| { | ||||||
| sta::Delay minimum = std::numeric_limits<sta::Delay>::max(); | ||||||
| sta::Delay minimum = std::numeric_limits<float>::max(); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| if (!visibility or isVisible()) { | ||||||
| if (parent_ != nullptr) { | ||||||
| for (const auto& [driver, arrival] : drivers_) { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using std::numeric_limits::max(), it is more idiomatic in this codebase to use sta::INF. This constant is already used for similar purposes elsewhere in this file (e.g., lines 1027 and 1204).
References