Skip to content
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

exp10(Dec128(0)) produces incorrect result #47

Closed
jmkuhn opened this issue Oct 10, 2017 · 12 comments
Closed

exp10(Dec128(0)) produces incorrect result #47

jmkuhn opened this issue Oct 10, 2017 · 12 comments

Comments

@jmkuhn
Copy link
Contributor

jmkuhn commented Oct 10, 2017

julia> exp10(Dec32(0))
+1E+0

julia> exp10(Dec64(0))
+1E+0

julia> exp10(Dec128(0))
+0E+0
@stevengj
Copy link
Member

Oh weird, I see the same thing! This looks like it could be a bug in the underlying library.

@stevengj
Copy link
Member

stevengj commented Oct 10, 2017

Yup, the source code bid128_exp10.c contains the lines:

    // x is 0, return 1.0
	 res.w[BID_HIGH_128W] = 0x3040000000000000ull;
	 res.w[BID_LOW_128W] = 0;
     BID_RETURN (res);

whereas I think it should be res.w[BID_LOW_128W] = 1 since reinterpret(UInt128, Dec128(1)) is 0x30400000000000000000000000000001

I submitted a bug report to [email protected].

@stevengj
Copy link
Member

stevengj commented Oct 10, 2017

Even simpler, the code for bid128_exp2.c and bid128_exp.c uses res = BID128_1 for the same condition, since BID128_1 is apparently a predefined constant for 1.0.

@stevengj
Copy link
Member

Intel responded to confirm the problem:

Thank you for pointing this out. Indeed, this is a corner case that requires a correction…
I believe your change is correct (I will double-check and will confirm). We will also post an updated library in the coming days.

@quinnj
Copy link
Collaborator

quinnj commented Jan 11, 2018

@stevengj, do you know if the library was updated? Do we need to do anything to build the new version?

@stevengj
Copy link
Member

stevengj commented Jan 11, 2018

I don't see any updates on Intel's website; I pinged them again via email to see what the timeframe is. Once we have an updated library (or we patch it ourselves if they don't update soon), we'll have to build new Mac and Windows binaries and post them on bintray.

@stevengj
Copy link
Member

I just got an email from them that they plan a new release "within days."

@quinnj
Copy link
Collaborator

quinnj commented Mar 2, 2018

@stevengj, do you have an official diff/patch for the fix? I have the BinaryBuilder/BinaryProvider working for all platforms now, so we could apply the fix ourselves until Intel gets around to releasing the new version.

@stevengj
Copy link
Member

stevengj commented Mar 3, 2018

I have an unofficial copy of version 20U2, but I'm not sure if I'm supposed to distribute it. They are allegedly going to post it within a week. In the meantime, you can just use my one-line patch res.w[BID_LOW_128W] = 1 from above.

@stevengj
Copy link
Member

Version 20U2 was just officially released: https://www.netlib.org/misc/intel/IntelRDFPMathLib20U2.tar.gz

@jmkuhn
Copy link
Contributor Author

jmkuhn commented Jun 22, 2018

In April I submitted a PR to DecFPBuilder quinnj/DecFPBuilder#6 for updates to BinaryBuilder. I'm not sure if there have been any significant changes to BinaryBuilder since then.

@jmkuhn
Copy link
Contributor Author

jmkuhn commented Mar 29, 2020

Fixed with #106

@jmkuhn jmkuhn closed this as completed Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants