Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add note on nans; remove unnecessary asserts
  • Loading branch information
mdickinson committed Feb 12, 2023
commit c381e4c1170fe02efcde3a7d61719e4aecbf741c
6 changes: 3 additions & 3 deletions Python/pytime.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,10 @@ pytime_double_to_denominator(double d, time_t *sec, long *numerator,
assumption that time_t is a two's complement integer type with no trap
representation, and that `PY_TIME_T_MIN` is within the representable
range of a C double.

Note: we want the `if` condition below to be true for NaNs; therefore,
resist any temptation to simplify by applying De Morgan's laws.
*/
assert(fmod(intpart, 1.0) == 0.0);
if (!((double)PY_TIME_T_MIN <= intpart && intpart < -(double)PY_TIME_T_MIN)) {
pytime_time_t_overflow();
return -1;
Expand Down Expand Up @@ -369,7 +371,6 @@ _PyTime_ObjectToTime_t(PyObject *obj, time_t *sec, _PyTime_round_t round)
(void)modf(d, &intpart);

/* See comments in pytime_double_to_denominator */
assert(fmod(intpart, 1.0) == 0.0);
if (!((double)PY_TIME_T_MIN <= intpart && intpart < -(double)PY_TIME_T_MIN)) {
pytime_time_t_overflow();
return -1;
Expand Down Expand Up @@ -537,7 +538,6 @@ pytime_from_double(_PyTime_t *tp, double value, _PyTime_round_t round,
d = pytime_round(d, round);

/* See comments in pytime_double_to_denominator */
assert(fmod(d, 1.0) == 0.0);
if (!((double)_PyTime_MIN <= d && d < -(double)_PyTime_MIN)) {
pytime_time_t_overflow();
return -1;
Expand Down