www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/15/12:46:14

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: QUAD_WORD (unsigned long long) bit testing
Date: Fri, 14 Nov 1997 17:49:40 -0500
Organization: Cornell University http://www.cornell.edu
Lines: 49
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <346CD584.F0A15C04@cornell.edu>
References: <346C8264 DOT 4C58AAA1 AT lausd DOT k12 DOT ca DOT us>
Reply-To: asu1 AT cornell DOT edu
NNTP-Posting-Host: cu-dialup-0059.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

csantill wrote:
> 
> from: csantill AT lausd DOT k12 DOT ca DOT us
> 
> Is it possible to do bit testing on the DJGPP data type "long long"?
> It doesn't seem to work the standard way of bits like this(this is for
> longs):

<snip>

type:
info gcc index "long long"

press enter.


try out:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
 unsigned long long int v1, v2;

 /* check if the 48th bit is set */
 static const unsigned long long int f = 0x0000800000000000ULL;

 srand(time(NULL));

 v1 =  rand();
 v2 =  rand();

 v1 = v1 + (v2 << 32);

 printf("%16.16llX\tFlag:%s\n", v1, (v1 & f) > 0 ? "SET" : "RESET");

 return 0;
}

-- 
----------------------------------------------------------------------
A. Sinan Unur
Department of Policy Analysis and Management, College of Human Ecology,
Cornell University, Ithaca, NY 14853, USA

mailto:sinan DOT unur AT cornell DOT edu
http://www.people.cornell.edu/pages/asu1/

- Raw text -


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