Open Bug 1260851 Opened 9 years ago Updated 3 years ago

FloatingPoint<double>::kMaxSafeInteger

Categories

(Core :: MFBT, defect)

defect

Tracking

()

People

(Reporter: jorendorff, Unassigned)

Details

Attachments

(2 files)

As requested in bug 1255128 comment 5.
Assignee: nobody → jorendorff
Status: NEW → ASSIGNED
Comment on attachment 8736439 [details] [diff] [review] Part 1: Add mozilla::FloatingPoint<T>::kMaxSafeInteger Review of attachment 8736439 [details] [diff] [review]: ----------------------------------------------------------------- ::: mfbt/FloatingPoint.h @@ +125,5 @@ > */ > static_assert(sizeof(T) == sizeof(Bits), "Bits must be same size as T"); > + > + static_assert(Base::kExponentShift + 1 < 64, "kMaxSafeInteger needs to have a bigger type"); > + static const uint64_t kMaxSafeInteger = (uint64_t(1) << (Base::kExponentShift + 1)) - 1; We could make this static MOZ_CONSTEXPR_VAR T kMaxSafeInteger = T((Bits(1) << (Base::kExponentShift + 1)) - 1); if we're willing to sacrifice constant-ness when we lack constexpr support. Seems somewhat doubtful we can/should, for all of these. So let's also add #ifndef MOZ_CONSTEXPR_VAR # error "kMaxSafeInteger should be made a T now that we have reliable constexpr support." #endif so this gets improved to that ideal state once that's possible.
Attachment #8736439 - Flags: review?(jwalden+bmo) → review+
Comment on attachment 8736441 [details] [diff] [review] Part 2: Use the new constant where appropriate in the JS engine Review of attachment 8736441 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for these, even if I made you "omg". :-) ::: js/src/jsnum.h @@ +273,1 @@ > double len = JS::ToInteger(argument); // Step 1. @@ +273,3 @@ > double len = JS::ToInteger(argument); > if (len <= 0) > return 0; // Step 2. @@ +278,1 @@ > return len; // Step 3. return js::Min<double>(len, mozilla::FloatingPoint<double>::kMaxSafeInteger); or if we had constexpr support, just std::min (but we don't).
Attachment #8736441 - Flags: review?(jwalden+bmo) → review+

The bug assignee didn't login in Bugzilla in the last 7 months.
:sg, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: jorendorff → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(simon.giesecke)
Flags: needinfo?(simon.giesecke)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: