- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I'm on MacOS, and am following the guide Using the Intel® Math Library to implement the first example:

```
// real_math.c
#include <stdio.h>
#include <mathimf.h>
int main() {
float fp32bits;
double fp64bits;
long double fp80bits;
long double pi_by_four = 3.141592653589793238/4.0;
// pi/4 radians is about 45 degrees
fp32bits = (float) pi_by_four; // float approximation to pi/4
fp64bits = (double) pi_by_four; // double approximation to pi/4
fp80bits = pi_by_four; // long double (extended) approximation to pi/4
// The sin(pi/4) is known to be 1/sqrt(2) or approximately .7071067
printf("When x = %8.8f, sinf(x) = %8.8f \n", fp32bits, sinf(fp32bits));
printf("When x = %16.16f, sin(x) = %16.16f \n", fp64bits, sin(fp64bits));
printf("When x = %20.20Lf, sinl(x) = %20.20Lf \n", fp80bits, sinl(fp80bits));
return 0;
}
```

As directed in the guide, I compile with:

`icc real_math.c`

When I execute, I get:

```
When x = 0.78539819, sinf(x) = 0.70710677
When x = 0.7853981633974483, sin(x) = 0.7071067811865475
When x = 0.78539816339744830952, sinl(x) = 0.00000000000000000000
```

**I've searched wide and far, and all examples seem to show that this should be trivial. What am I missing?**

I tried to pass `-long_double`

to `icc`

, but nothing changes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Ok, I figured it out. This problem was caused by an error on my part due to the omission of 1 character: `L`

. Specifically, somehow in my own code on my computer I had this:

```
printf("When x = %20.20Lf, sinl(x) = %20.20f \n", fp80bits, sinl(fp80bits));
```

and the correct code is this (note `%20.20f`

vs `%20.20Lf`

```
printf("When x = %20.20Lf, sinl(x) = %20.20Lf \n", fp80bits, sinl(fp80bits));
```

I'm not even sure how this could have happened, but this was the root cause.

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Ok, I figured it out. This problem was caused by an error on my part due to the omission of 1 character: `L`

. Specifically, somehow in my own code on my computer I had this:

```
printf("When x = %20.20Lf, sinl(x) = %20.20f \n", fp80bits, sinl(fp80bits));
```

and the correct code is this (note `%20.20f`

vs `%20.20Lf`

```
printf("When x = %20.20Lf, sinl(x) = %20.20Lf \n", fp80bits, sinl(fp80bits));
```

I'm not even sure how this could have happened, but this was the root cause.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

We have tried to run the attached source code which you have provided, and we don't see any issues.

Could you please confirm if your issue is resolved?

If resolved, let us know if we can close this thread from our side.

Thanks & Regards

Goutham

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

Glad to know that your issue is resolved!

Thanks for the confirmation!

As this issue has been resolved, we will no longer respond to this thread.

If you require any additional assistance from Intel, please start a new thread.

Any further interaction in this thread will be considered community only.

Have a Good day!

Thanks & Regards

Goutham

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page