www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/02/19:00:05

From: "Thomas Harte" <T DOT Harte AT btinternet DOT com DOT KILL_PART>
Newsgroups: comp.os.msdos.djgpp
Subject: RE : hex calculation routine!?
Date: Sat, 2 Sep 2000 23:54:23 +0100
Organization: BT Internet
Lines: 17
Message-ID: <8os0j3$bba$1@neptunium.btinternet.com>
NNTP-Posting-Host: host62-7-104-29.btinternet.com
X-Newsreader: Microsoft Outlook Express 4.72.3155.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
Path: news.mv.net!newspeer.phoen-x.net!diablo.netcom.net.uk!netcom.net.uk!newsfeeds.belnet.be!news.belnet.be!btnet-peer1!btnet-peer0!btnet!mendelevium.btinternet.com!not-for-mail
Xref: news.mv.net comp.os.msdos.djgpp:103113

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

Hex calculations are done exactly as any other, just be aware that if in
code you want to write a hex number, e.g. 2A, C expects '0x2A', and that to
get printf to display hex digits, use %x rather than %d. E.g. :

a = 0x800F0F0F+0x8F0;
printf("%x", a);

Yields '800F17FF' on the standard output.

-Thomas


- Raw text -


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