delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/25/22:03:00

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Converting doubles to ints and chars!?
Date: Fri, 25 Jul 1997 08:54:36 -0700
Organization: Alcyone Systems
Message-ID: <33D8CC3C.147839DD@alcyone.com>
References: <33d535b4 DOT 193109 AT news DOT algonet DOT se>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
Lines: 42
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Christian Granström wrote:

> I tried to typecast them like:
> 
> double X:
> unsigned char Y;
> 
> Y = (unsigned char X);

This is a syntax error.  You mean:

    double d;
    unsigned char uc;

    uc = (unsigned char) d;

> This seems to work until i put Y into an vector. Compilator bug???
> It also works fine if I printf() Y before puting it into the vector!

If my vector you mean array (they're not called vectors in C), then it
just looks like this:

    double da[];
    unsigned char uc;

    uc = (unsigned char) da[i];

> Maybe its not supposed to be done this way at all but the
> compiler does'nt complain about it!!

It shouldn't have worked at all.

-- 
       Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
                     Alcyone Systems /   web / http://www.alcyone.com/max/
San Jose, California, United States /  icbm / 37 20 07 N  121 53 38 W
                                   \
   "Love is not love which alters / when it alternation finds."
                                 / William Shakespeare, _Sonnets_, 116

- Raw text -


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