Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > type conversion float and long

Reply
Thread Tools

type conversion float and long

 
 
sriamar
Guest
Posts: n/a
 
      01-21-2005
Hello,

How does the type conversion work if the expression involves a float
and long int?

By K&R 2nd Ed i assume
float & long -> float & float .

But does the 'long' qualifier affect this in any way?. Because I dont
remember seeing something like 'long float ' anywhere and only 'long
double' exists.

Can somebody clarify this please.

Amar

 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      01-21-2005
"sriamar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hello,
>
> How does the type conversion work if the expression involves a float
> and long int?
>
> By K&R 2nd Ed i assume
> float & long -> float & float .


Well, that's certainly not a valid C expression.
Exactly what did you read, and where, in K&R2?

>
> But does the 'long' qualifier affect this


Affect what?

>in any way?. Because I dont
> remember seeing something like 'long float ' anywhere and only 'long
> double' exists.


There is no long float.

There are:

long int
unsigned long int
signed long int (which is the same thing as long int)
long double
long nights without enough coffee

Perhaps you were reading about 'double' having greater range
and precision than that required 'float', and (informally)
being called a 'long float', or 'longer float'. But there's
no actual such type in C.

-Mike


 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      01-22-2005
On 21 Jan 2005 08:49:02 -0800, "sriamar" <(E-Mail Removed)> wrote in
comp.lang.c:

> Hello,
>
> How does the type conversion work if the expression involves a float
> and long int?
>
> By K&R 2nd Ed i assume
> float & long -> float & float .
>
> But does the 'long' qualifier affect this in any way?. Because I dont
> remember seeing something like 'long float ' anywhere and only 'long
> double' exists.
>
> Can somebody clarify this please.
>
> Amar


If an expression involves a float and any integer type, any at all,
the value of the integer is converted to a float. The 'long' in "long
int" is not a qualifier, it is part of the type. And it makes no
difference.

We can go further and state the general rule: in any operation
involving any floating point type and any integer type, the value of
the integer type is converted to the floating point type. Which
floating point type and which integer type is immaterial.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
float to string to float, with first float == second float Carsten Fuchs C++ 45 10-08-2009 09:47 AM
Having compilation error: no match for call to (const __gnu_cxx::hash<long long int>) (const long long int&) veryhotsausage C++ 1 07-04-2008 05:41 PM
Float to int conversion by using two int variables for representation of the float variable k3n3dy C++ 15 04-20-2006 06:53 PM
conversion from type 'DBNull' to type 'float' is not valid ibiza ASP .Net 2 01-27-2006 09:57 PM
Re: float->byte->float is same with original float image. why float->ubyte->float is different??? bd C Programming 0 07-07-2003 12:09 AM



Advertisments