delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/22/16:15:24

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: double trouble
Date: Sat, 22 Aug 1998 16:13:47 -0300
Organization: NBTel Internet
Lines: 25
Message-ID: <35DF186B.AD8C5746@unb.ca>
References: <35DEDC2F DOT BB81D366 AT virgin DOT net> <6rmjlm$oao$1 AT news DOT luth DOT se> <35DEF229 DOT 8A4A71FC AT virgin DOT net>
NNTP-Posting-Host: fctnts11c02.nbnet.nb.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Stephen Snape wrote:

> yes, sorry, this isn't my actual code, I wrote it in the mail quickly, I
> know I forgot the semis etc. What I am trying to do is find out if a 'bit'
> in a double is ON or OFF and return the value. So I am using the int to
> shift through the double and return the value, but I am getting errors. I
> don't want to use a long because I need 64 bits!

    If you want to use a 64-bit integer, then you can use 'long long's.  They
work.  Bit-shifting a double wouldn't produce the arithmetic results you would
expect.  If you do want to quickly multiply (or divide) by powers of 2, then
you can do this:void QuickMultBy2(double& a)
{
 *((lword*)&a+1) += 0x100000;
 }


--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlis AT nbnet DOT nb DOT ca



- Raw text -


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