delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/05/04/04:02:11

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: niklaus AT gamebox DOT net (Niklaus)
Newsgroups: comp.os.msdos.djgpp
Subject: typecast internals
Date: 4 May 2004 00:58:40 -0700
Organization: http://groups.google.com
Lines: 44
Message-ID: <d06ac2eb.0405032358.6c5035f1@posting.google.com>
NNTP-Posting-Host: 210.18.90.1
X-Trace: posting.google.com 1083657521 17116 127.0.0.1 (4 May 2004 07:58:41 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Tue, 4 May 2004 07:58:41 +0000 (UTC)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,
  I would like to know more about casts.What exactly happens
  when casts are applied to a variable.I know that if an
  object of type int is applied an cast of float the result
  would be of type float.

1)
    What i would like to know is the about the
    internals when a cast is applied ? Say we have

                   int i = 3;
                   double j;
                   j = (double) i;
     
     What happens in the above statement  ? Can someone
     explain me at bit level or a considerable explantion ?
     

2)
     Also i would like to know what happens say

                  i = (int)j;

     Again an explanation at the bit level would be very helpful.
     If we have

3)

                  float f = 4.3;
                  int i;
                  i = (int) f;

    What happens here ? How does the truncation take place ? 
4)
     Is it similar to how int got promoted to double in the question 2.
5)
     How are side effects defined ? When do
     i say typecasting is an side  effect ?

6)
    Is truncation a side effect of type casting or not ?

Nik
-

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019