http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> writes:

> In article <Xd%6u.1$(E-Mail Removed)>,

> Bill Cunningham <(E-Mail Removed)> wrote:

>> James Kuyper wrote:

>

> [ snip ]

>

>> Wow. Talk about knowing your stuff! You know I've never used a

>> float. This post has just made me think. I've always used

>> doubles. Do people even use the float type anymore? I can't recall

>> ever seeing a C89 or C99 standard function accepting a float. But

>> then again I don't know much.

>>

>

> Fairly old post, but possibly still worth replying ....

>

> At least some of the math-library functions seem to have a version

> that accepts and returns doubles, and another that accepts/returns

> floats. Example are fabs/fabsf and sin/sinf. So, yeah, in this

> respect you don't know much (though why should you, really).
C90's <math.h> only defined functions with arguments and results of type

double. If you wanted a square root of a float, you could use the

double function and convert the argument and result:

float x = 2.0;

float sqrt_x = sqrt(x); /* two implicit conversions */

If you wanted long double, you were out of luck unless you had a

non-standard library.

C99 added float and long double versions of the math functions, so now

we have:

double sqrt(double x);

float sqrtf(float x);

long double sqrtl(long double x);

It also added <tgmath.h>, which defines a number of "type-generic

macros", so that sqrt(x) would invoke either sqrtl(), sqrt(), or

sqrtf(), depending on the type of the argument.

C11 added _Generic, which allows programmers to do the same kind of

thing <tgmath.h> does.

[...]

--

Keith Thompson (The_Other_Keith)

(E-Mail Removed) <http://www.ghoti.net/~kst>

Working, but not speaking, for JetHead Development, Inc.

"We must do something. This is something. Therefore, we must do this."

-- Antony Jay and Jonathan Lynn, "Yes Minister"