delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/24/21:35:31

From: derek AT algonet DOT se (Christian Granström)
Newsgroups: comp.os.msdos.djgpp
Subject: Converting doubles to ints and chars!?
Date: Tue, 22 Jul 1997 22:38:54 GMT
Organization: RAGE
Lines: 23
Message-ID: <33d535b4.193109@news.algonet.se>
NNTP-Posting-Host: du174-5.ppp.algonet.se
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

How do I convert an double to an int or an unsigned char???

I tried to typecast them like:

double X:
unsigned char Y;

Y = (unsigned char X);

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!

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

How do I do it in a proper way?

------------------------------------------------------------------------
      Christian Granström, Bryggerigatan 4A, 733 34 Sala, Sweden
    derek AT algonet DOT se, christiang AT pasdata DOT se, www.algonet.se/~derek
                 +46(0)22477312, +46(0)704961587
------------------------------------------------------------------------

- Raw text -


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