I'm just looking at the lack of elegance - that's pretty much it.
I've no objection to inelegant code (of which I've written heaps) if it needs to be that way.
If not for the portability concerns, I'd pick up on
stevieb's suggestion and just have the XSub as :
int uv_fits_double(UV arg) {
arg >>= __builtin_ctzll(arg);
if(arg < 9007199254740993) return 1;
return 0;
}
That seems to work fine on MinGW-built Windows perls, where $Config{ivtype} is 'long long', and I'd be happy with that even if it wasn't any more efficient.
I didn't know about the existence of __builtin_ctz() and friends. Thanks,
stevieb for bringing it to my attention. I'll do some benchmarking later on, and see how much time it saves.
It's an option that could come in handy to me in the future.
I guess that, mainly, I just want to know if there are some more elegant (&& portable) options available.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.