Skip to content

Commit

Permalink
follow up to #4808: avoid type pun dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdowle committed Nov 13, 2020
1 parent 70a598d commit 8480b6a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/fsort.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ SEXP fsort(SEXP x, SEXP verboseArg) {
// avoid twiddle function call as expensive in recent tests (0.34 vs 2.7)
// possibly twiddle once to *ans, then untwiddle at the end in a fast parallel sweep

uint64_t maxULL = *(uint64_t *)&max;
minULL = *(uint64_t *)&min; // set static global for use by dradix_r
union {double d; uint64_t u64;} u;
u.d = max;
uint64_t maxULL = u.u64;
u.d = min;
minULL = u.u64; // set static global for use by dradix_r

int maxBit = floor(log(maxULL-minULL) / log(2)); // 0 is the least significant bit
int MSBNbits = maxBit > 15 ? 16 : maxBit+1; // how many bits make up the MSB
Expand Down

0 comments on commit 8480b6a

Please sign in to comment.