help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Decimal to Hexadecimal - But not in the way you think!


From: Richardson, Anthony
Subject: RE: Decimal to Hexadecimal - But not in the way you think!
Date: Thu, 15 Nov 2018 21:46:36 +0000

> Subject: Decimal to Hexadecimal - But not in the way you think!
> 
> For reasons I won't go into (another application), I need to convert a decimal
> number into a hexadecimal number - but not in the usual way.
> 
> As an example I need to convert the integer "*14*" into the hexadecimal
> number "0x*14*"
> 
> Is there a simple way to do this? I thought of number  -> string -> number,
> but there's no string to hex conversion as far as I can see.
> 
> I could do it by taking the integer "14", splitting it up into 1 and 4, taking
> (1*16)+(4) = 20 and then converting 20 to a hex number which gives me
> "0x14", but is there a simpler way to do this that I'm missing?
> 

How about this:

>> n = sscanf(num2str(14), "x")
N = 20

Tony Richardson



reply via email to

[Prev in Thread] Current Thread [Next in Thread]