Mercurial > octave
comparison libinterp/octave-value/ov.cc @ 30860:fc045a84cb33
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Wed, 23 Mar 2022 18:28:24 +0100 |
parents | 1be26e9c07e3 df26decca96b |
children | 79edd49a5a97 |
comparison
equal
deleted
inserted
replaced
30858:820466e45a93 | 30860:fc045a84cb33 |
---|---|
3248 | 3248 |
3249 static const UT max_val = std::numeric_limits<UT>::max (); | 3249 static const UT max_val = std::numeric_limits<UT>::max (); |
3250 | 3250 |
3251 double abs_increment = std::abs (increment); | 3251 double abs_increment = std::abs (increment); |
3252 | 3252 |
3253 if (abs_increment > max_val) | 3253 // Technically, this condition should be `abs_increment > max_val`. |
3254 // But intmax('uint64') is not representable exactly as floating point | |
3255 // number. Instead, it "rounds" up by 1 to 2^64. To account for | |
3256 // this, use the following expression which works for all unsigned | |
3257 // integer types. | |
3258 if ((abs_increment-1.) >= max_val) | |
3254 return 1; | 3259 return 1; |
3255 | 3260 |
3256 UT unsigned_increment = range_increment<T> (increment); | 3261 UT unsigned_increment = range_increment<T> (increment); |
3257 | |
3258 // If the increment wasn't zero before but it is now, the cast to UT | |
3259 // wrapped around. The range can only have one value. | |
3260 if (unsigned_increment == 0) | |
3261 return 1; | |
3262 | 3262 |
3263 return range_numel_aux (base, unsigned_increment, limit); | 3263 return range_numel_aux (base, unsigned_increment, limit); |
3264 } | 3264 } |
3265 | 3265 |
3266 // Make a range from integer values. Increment may be integer or double. | 3266 // Make a range from integer values. Increment may be integer or double. |