-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Low-level Constructors #14
Comments
I think you'd have to poke around in the Intel libraries (although I'd like to investigate whether we should switch to the IBM library). |
I don't see any exported functions, but there are some undocumented internal functions that may do what you want, e.g. (from // No overflow/underflow checking
//
__BID_INLINE__ BID_UINT64
fast_get_BID64 (BID_UINT64 sgn, int expon, BID_UINT64 coeff) {
BID_UINT64 r, mask;
mask = 1;
mask <<= EXPONENT_SHIFT_SMALL64;
// check whether coefficient fits in 10*5+3 bits
if (coeff < mask) {
r = expon;
r <<= EXPONENT_SHIFT_SMALL64;
r |= (coeff | sgn);
return r;
}
// special format
// eliminate the case coeff==10^16 after rounding
if (coeff == 10000000000000000ull) {
r = expon + 1;
r <<= EXPONENT_SHIFT_SMALL64;
r |= (1000000000000000ull | sgn);
return r;
}
r = expon;
r <<= EXPONENT_SHIFT_LARGE64;
r |= (sgn | SPECIAL_ENCODING_MASK64);
// add coeff, without leading bits
mask = (mask >> 2) - 1;
coeff &= mask;
r |= coeff;
return r;
} This is inlined, and so it can't be called from the C shared library, but it looks easy enough to rewrite in Julia. |
@quinnj - Assuming this constructor is still useful for you, please look over the following proposed API and let me know if it does what you need and if you would suggest any changes.
The 3 argument version is designed to be efficient so it usually doesn't require any multiplication, division, or exponentiation. It will use division if the supplied Some more examples:
|
Maybe define |
This looks great! Yeah, I'm actually rewriting ODBC.jl now and still doing conversions to/from strings for As ODBC.jl also allows sending data to the database, it would also be nice to have the inverse of this functionality: given a |
There is an unexported function that returns integer + exponent. The current version ignores sign. I can add sign and export this.
This function is available in the current master, but not yet in a released version. |
With this new constructor and a public dumper, we will need to handle |
Why would you need Inf and NaN, since we already have compile-time constants for those? |
My original thinking was that if we have a pair of functions,
But, we don't need the constructor to be able to handle
|
Closed by #129. |
@stevengj, what are the options for low level construction of a
Dec64
type? I poked around the source code, but it seems like pretty much everything funnels throughparse
. I ask because I'm looking at ODBC interop, where the ODBC SQL type is defined aswhich the ODBC driver manager would fill in the bits, and then ODBC.jl defines the appropriate conversion routine from
SQLNumeric
toDec64
. Any thoughts or perhaps I need to dig into the Intel header files a little.The text was updated successfully, but these errors were encountered: