Reading specific memory address into variable

From: David Casey (sgtcasey_at_IH8SPAMcableone.net)
Date: 10/20/04


Date: Tue, 19 Oct 2004 21:41:44 -0600

I'm working on a program for my C++ class and have it all written and
working except for one part. I need to compare two numeric variables to
determine decimal accuracy between them. For example:

pi = 3.14159...
mynum = 3.14226...

The mynum is accurate to 2 decimal places compared to pi. I could figure
this out easy with a char array since I could just take a character one at
a time from each array and compare it. However with a numeric variable I'm
coming up short trying to figure this out.

I've had other ideas, but I can't seem to make any of them work right so I
figured I'd go back to my original idea which is to figure out where in
memory the variable is stored using a pointer. Then read each digit in
individually and compare it with the same digit in the same position in the
other variable. If they are equal, add 1 to the precision variable. If
they're not, then leave the loop and the accuracy is whatever precision is
equal to.

I've spent quite a few hours tonight looking in all the C++ books I own and
searching both the Internet and Usenet but to no avail. I suppose I'm
looking for a way to do what I was able to in BASIC all those years ago
like the peek command which would return whatever was in a specific memory
location.

I'm not looking to be given an answer to my problem, just a nudge in the
right direction so I can find it myself. Thanks to any help anyone can
provide.

Dave

-- 
You can talk about us, but you can't talk without us!
US Army Signal Corps!!
http://www.geocities.com/davidcasey98
Remove IH8SPAM to reply by email!


Relevant Pages

  • Re: low-value
    ... >> Don't make code with 2 digit years, especially if you are going to ... >> compare dates. ... Memory and disk space are cheap, ...
    (comp.lang.cobol)
  • Re: Well Ordering the Reals
    ... > But if one has infinitely many digit positions between two ... If the string between them is defined, either with a bit pattern or as ... With one point you can define a finite neighborhood. ... The only places he CAN compare bit patterns are at ...
    (sci.math)
  • Re: Well Ordering the Reals
    ... >>> points and into the neighbor hood of another. ... > If TO is to have only finitely many digit positions between two of his ... If the string between them is defined, either with a bit pattern or as equal to ... The only places he CAN compare bit patterns are at ...
    (sci.math)
  • Re: Sorting algorithm when comparison is heavy
    ... asking about sorting things with very expensive compare operations. ... single digit of the long value. ... sorted pile after handling the most significant digit. ...
    (comp.programming)
  • Re: Unix C programming for finding file
    ... >> to memory map the two files and then call memcmp(). ... You can only avoid loading all files into memory if you compare ... After that test you still have to load the remaining files to be ...
    (comp.unix.programmer)