Re: Hex--->Dec!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Arpan wrote:
>
> Nope....Duane....that isn't what I am looking out for. Let me give you
> an example.
>
> Consider the decimal number 10. The hexadecimal equivalent of 10 is 'A'
> (without the quotes) which can be computed using Hex(10). Now I want a
> function that will convert the hexadecimal 'A' back to decimal 10.

That's <exactly> what I demonstrated...

Go through my example...

?hex$(10)
A
?"&H" & hex$(10)
&HA

So, "&H" & hex$(10), the argument to Val() is "&HA".

The &H is needed to satisfy VB's syntax rules to identify the string "A"
to Val() as being interpreted as a hex value.

?val("&H" & hex$(10))
10

> Similarly, the octal equivalent of 10 is 12 which can be computed using
> Oct(10). Now I want a function that will convert the octal 12 back to
> decimal 10.

Same thing...

> I hope I am clear enough now. ...

You're confusing internal and external representations, methinks...

The decimal value is stored internally as a bit pattern of 000010010
(upper bits implied and all 0). Whether you see "10" or "A" or "12" is
simply what base system is used for presentation--the internal
representation is unchanged.

As noted, there are syntax rules in VB regarding what you have to do to
present ASCII representations to various functions/statements to make
the interpretation and presentation as desired.

If you would describe the actual application/problem domain specific
solutions might be forthcoming.
.



Relevant Pages

  • Re: Null terminated strings: bad or good?
    ... value that an expression with the type size_t (such as a sizeof expression) ... That definitely sounds like a very unorthodox interpretation ... a conversion from size_t to size_t is not supposed to change the value ...
    (comp.std.c)
  • Re: floating point number input conversion tests
    ... number interpretation and output, I posted the following program, ... number reduces to the expected IEEE single and double precision ... representations. ...
    (comp.lang.forth)
  • Re: type writers and tooth aches II
    ... > But you are forgetting that that whole interpretation is a result of ... if my representations get out of sync with the world, ... > nutrition, a body to interface them with the environment, sensory input ... It's justified by the fact that that the brain use representations, ...
    (comp.ai.philosophy)
  • Trap representations in the absence of padding bits
    ... representations are not interpreted at all doesn't change that. ... notation" does not mention trap representations. ... padding bits the definition of "pure binary notation" would not ... My interpretation differs from yours only in that I ...
    (comp.lang.c)