delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/03/12:00:05.6

From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p>
Newsgroups: comp.lang.c,comp.os.msdos.djgpp
Subject: Re: hex calculation routine!?
Organization: Pin Eight Software http://pineight.8m.com/
Message-ID: <nns4rssto1eudtvktejqkhjkee3vdtje5e@4ax.com>
References: <p2m2rsg34070tpo2vvia7bdlugv6h3g107 AT 4ax DOT com>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Lines: 25
X-Trace: /Kw5eDXQmUmeBZqvDCJO5Xr7umyaU/V/VNhrATZguHOlF8VKQYhjKiJQ0TUeaUqEdD8RXzaGtTZN!clL+27dXCsZgbtsDURq2Pomr4eXzvl+txlYnd5VKaS7JuZbH/0Ty50BNEGhw2K/fwkio2EhtGZjR!16cN/DA=
X-Complaints-To: abuse AT gte DOT net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Sun, 03 Sep 2000 15:52:29 GMT
Distribution: world
Date: Sun, 03 Sep 2000 15:52:29 GMT
Path: news.mv.net!newspeer.phoen-x.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.direct.ca!look.ca!paloalto-snh1.gtei.net!news.gtei.net!dfiatx1-snr1.gtei.net.POSTED!not-for-mail
Xref: news.mv.net comp.lang.c:420537 comp.os.msdos.djgpp:103133

Posted and emailed to ^Hawk^ <Hawk AT DarkSoft DOT Net>:

>Has anybody a routine to add/subtract etc. hex-values for me? Thnx in
>advance! =;)
>
>ie. 800F0F0F+8F0=??? or 800F0F0F-8F0=???.

/* assuming unsigned long is a 32-bit or larger data type */

unsigned long foo = 0x800f0f0f
unsigned long bar = 0x8f0

printf("%lx - %lx = %lx\n", foo, bar, foo - bar);

IIRC, %x prints an int as hexadecimal, and %lx prints a long as
hexadecimal.  Crossposted to comp.lang.c for further comment on this
portable language issue.

-- 
MS (n)  1. A debilitating and surprisingly widespread affliction
  that renders the sufferer barely able to perform the simplest
  task.  2. A disease, multiple sclerosis (see).

This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses.  http://www.mcafee.com/

- Raw text -


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