- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
what is the fastest way to test at runtime, to machine accuracy,
if double d2 is between d1 and d3 while not knowing d1 and d3 in advance?
double d1 =...;
double d2 =...;
double d3=...;
if ( d1>d3 && d1>=d2 && d2>=d3 ) || ( d1
regards,
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The answer is highly platform and data dependent. You might consider whether & in place of &&, | in place of ||, might be appropriate for your case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
win64
core2 (up to ssse3) and penryn (sse4)
d1, d2, d3 are all within 0.0 and 1.0 range, but often between 0.0 and 0.1 range. relevant precision is 4th decimal.
i don't see how to use the bit-and and bit-or instead of logical ones.
rds,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
// highest prob. lowest prob.
if((d1// d2 between d1 and d3 regardless of sign
}
order the expressions left to right in order of highest probability
If your code requires d1 < d3 then use only left expression
Jim
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page