Mike Torrettinni 198 Posted May 14, 2021 On 5/12/2021 at 5:41 AM, Stefan Glienke said: (it is coded in a bad way plus the compiler produces way too many conditional jumps - https://quality.embarcadero.com/browse/RSP-21955) It's almost 3 years old report and no comments from the support team. I assume this will no be improved for 10.5. Too bad. Share this post Link to post
Mike Torrettinni 198 Posted May 14, 2021 On 5/12/2021 at 10:12 AM, Clément said: The code for IsInRangeEx and isInRangeEx2: function IsInRangeEx(const AValue, AMin, AMax: Cardinal): Boolean; inline; begin Result := (AValue - AMin) <= (aMax - aMin); end; function IsInRangeEx2(const AValue, AMin, AMax: Integer): Boolean; inline; begin Result := ((AValue-AMax)*(aValue-AMin) <= 0); end; Thanks, but these are some math tricks I can't figure out 😉 Share this post Link to post
Rollo62 536 Posted May 14, 2021 (edited) Need to be Edited again (lEditor lost all my text from 1st post). Seems mathematically correct, but may face internal integer overflows, to be tested in Delphi ... Edited May 14, 2021 by Rollo62 2 Share this post Link to post
Mike Torrettinni 198 Posted May 14, 2021 Interesting that all these calculations (- and * and comparison) are as fast as simple 2 value comparisons. Share this post Link to post