Re: [algogeeks] union- c

2010-06-13 Thread Anand
On Sun, Jun 13, 2010 at 4:10 AM, divya jain wrote:

> wat i meant is
> the ans of this questn is
> 10.00 0.00 3 1080263967
> now my questn is y u.f_e is printing 0.00 and similarly y u.l_e is
> giving this value...
>
> @ Divya:
Here 3.55 is stored as a floating point number after converting it to
mantisa and exponent. when you print the hex value of u.l_e you will get the
floating point number in below format. and %ld will print the decimal value
for it.
Hope this is clear.

*Format*

SEEE

EMMM





*Binary*

1101

01001000

 you



*Hex*

C1

48

00

00

http://codepad.org/UuvvUBTO

http://www.fsinc.com/reference/html/com9anm.htm


thanks,

Anand





> On 13 June 2010 15:08, Rohit Saraf  wrote:
>
>> If you are not able to print the long int and that's the prob, you can use
>> %ld instead of %d
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>> On Sun, Jun 13, 2010 at 1:49 PM, divya jain wrote:
>>
>>> its an o/p questn..
>>> conversion wen ur variable is long..nd u r printing using %f...i dont
>>> know how to perform conversion from float to int long nd vice versa..
>>> pl help
>>>
>>> On 13 June 2010 12:12, Rohit Saraf  wrote:
>>>
 what is this for...
 and which conversion are you talking abt?

 --
 Rohit Saraf
 Second Year Undergraduate,
 Dept. of Computer Science and Engineering
 IIT Bombay
 http://www.cse.iitb.ac.in/~rohitfeb14


 On Sat, Jun 12, 2010 at 11:20 PM, divya wrote:

> #include 
> main()
> {
>  union {
>  long l_e;
>  float f_e;
>  } u;
>
>  long l_v;
>  float f_v;
>  l_v = u.l_e = 10;
>  printf("%f ", (float)l_v);
>  printf("%f ", u.f_e);
>  f_v = u.f_e = 3.555;
>  printf("%d ", (long)f_v);
>  printf("%d ", u.l_e);
> }
> hw to do the conversion here..
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
  --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] union- c

2010-06-13 Thread divya jain
wat i meant is
the ans of this questn is
10.00 0.00 3 1080263967
now my questn is y u.f_e is printing 0.00 and similarly y u.l_e is
giving this value...
On 13 June 2010 15:08, Rohit Saraf  wrote:

> If you are not able to print the long int and that's the prob, you can use
> %ld instead of %d
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sun, Jun 13, 2010 at 1:49 PM, divya jain wrote:
>
>> its an o/p questn..
>> conversion wen ur variable is long..nd u r printing using %f...i dont know
>> how to perform conversion from float to int long nd vice versa..
>> pl help
>>
>> On 13 June 2010 12:12, Rohit Saraf  wrote:
>>
>>> what is this for...
>>> and which conversion are you talking abt?
>>>
>>> --
>>> Rohit Saraf
>>> Second Year Undergraduate,
>>> Dept. of Computer Science and Engineering
>>> IIT Bombay
>>> http://www.cse.iitb.ac.in/~rohitfeb14
>>>
>>>
>>> On Sat, Jun 12, 2010 at 11:20 PM, divya wrote:
>>>
 #include 
 main()
 {
  union {
  long l_e;
  float f_e;
  } u;

  long l_v;
  float f_v;
  l_v = u.l_e = 10;
  printf("%f ", (float)l_v);
  printf("%f ", u.f_e);
  f_v = u.f_e = 3.555;
  printf("%d ", (long)f_v);
  printf("%d ", u.l_e);
 }
 hw to do the conversion here..

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] union- c

2010-06-13 Thread Anurag Sharma
Check the floating point representation(IEEE 754 format) in variables. There
are specific number of bits in a float variable to represent exponent,
mantissa etc.

Anurag Sharma


On Sun, Jun 13, 2010 at 1:19 PM, divya jain wrote:

> its an o/p questn..
> conversion wen ur variable is long..nd u r printing using %f...i dont know
> how to perform conversion from float to int long nd vice versa..
> pl help
>
>
> On 13 June 2010 12:12, Rohit Saraf  wrote:
>
>> what is this for...
>> and which conversion are you talking abt?
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>> On Sat, Jun 12, 2010 at 11:20 PM, divya  wrote:
>>
>>> #include 
>>> main()
>>> {
>>>  union {
>>>  long l_e;
>>>  float f_e;
>>>  } u;
>>>
>>>  long l_v;
>>>  float f_v;
>>>  l_v = u.l_e = 10;
>>>  printf("%f ", (float)l_v);
>>>  printf("%f ", u.f_e);
>>>  f_v = u.f_e = 3.555;
>>>  printf("%d ", (long)f_v);
>>>  printf("%d ", u.l_e);
>>> }
>>> hw to do the conversion here..
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] union- c

2010-06-13 Thread Rohit Saraf
If you are not able to print the long int and that's the prob, you can use
%ld instead of %d
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sun, Jun 13, 2010 at 1:49 PM, divya jain wrote:

> its an o/p questn..
> conversion wen ur variable is long..nd u r printing using %f...i dont know
> how to perform conversion from float to int long nd vice versa..
> pl help
>
> On 13 June 2010 12:12, Rohit Saraf  wrote:
>
>> what is this for...
>> and which conversion are you talking abt?
>>
>> --
>> Rohit Saraf
>> Second Year Undergraduate,
>> Dept. of Computer Science and Engineering
>> IIT Bombay
>> http://www.cse.iitb.ac.in/~rohitfeb14
>>
>>
>> On Sat, Jun 12, 2010 at 11:20 PM, divya  wrote:
>>
>>> #include 
>>> main()
>>> {
>>>  union {
>>>  long l_e;
>>>  float f_e;
>>>  } u;
>>>
>>>  long l_v;
>>>  float f_v;
>>>  l_v = u.l_e = 10;
>>>  printf("%f ", (float)l_v);
>>>  printf("%f ", u.f_e);
>>>  f_v = u.f_e = 3.555;
>>>  printf("%d ", (long)f_v);
>>>  printf("%d ", u.l_e);
>>> }
>>> hw to do the conversion here..
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] union- c

2010-06-13 Thread divya jain
its an o/p questn..
conversion wen ur variable is long..nd u r printing using %f...i dont know
how to perform conversion from float to int long nd vice versa..
pl help

On 13 June 2010 12:12, Rohit Saraf  wrote:

> what is this for...
> and which conversion are you talking abt?
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
> On Sat, Jun 12, 2010 at 11:20 PM, divya  wrote:
>
>> #include 
>> main()
>> {
>>  union {
>>  long l_e;
>>  float f_e;
>>  } u;
>>
>>  long l_v;
>>  float f_v;
>>  l_v = u.l_e = 10;
>>  printf("%f ", (float)l_v);
>>  printf("%f ", u.f_e);
>>  f_v = u.f_e = 3.555;
>>  printf("%d ", (long)f_v);
>>  printf("%d ", u.l_e);
>> }
>> hw to do the conversion here..
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] union- c

2010-06-12 Thread Rohit Saraf
what is this for...
and which conversion are you talking abt?

--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Sat, Jun 12, 2010 at 11:20 PM, divya  wrote:

> #include 
> main()
> {
>  union {
>  long l_e;
>  float f_e;
>  } u;
>
>  long l_v;
>  float f_v;
>  l_v = u.l_e = 10;
>  printf("%f ", (float)l_v);
>  printf("%f ", u.f_e);
>  f_v = u.f_e = 3.555;
>  printf("%d ", (long)f_v);
>  printf("%d ", u.l_e);
> }
> hw to do the conversion here..
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] union- c

2010-06-12 Thread divya
#include 
main()
{
 union {
  long l_e;
  float f_e;
 } u;

 long l_v;
 float f_v;
 l_v = u.l_e = 10;
 printf("%f ", (float)l_v);
 printf("%f ", u.f_e);
 f_v = u.f_e = 3.555;
 printf("%d ", (long)f_v);
 printf("%d ", u.l_e);
}
hw to do the conversion here..

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.