help-octave
[Top][All Lists]
Advanced

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

Re: Masking using Hexadecimal Values


From: Chip Wachob
Subject: Re: Masking using Hexadecimal Values
Date: Thu, 4 Aug 2016 22:22:48 -0400

Sorry, I'm not used to this forum format...

Thanks, and your examples you provided make sense.

My range comment referred to an array of values. 

Thanks for being patient while I come up to speed.


On Thu, Aug 4, 2016 at 12:37 PM, Mike Miller <address@hidden> wrote:
On Thu, Aug 04, 2016 at 08:34:21 -0400, Chip Wachob wrote:
> Thank you everyone for the prompt replies.

I'll assume you meant to reply to everyone, but only replied to me.
Adding the help mailing list back in cc.

> I'll sort of handle this is reverse order..
>
> - Octave version is 4.0.3
> - Running on Windoze 7
> - I unzipped the dowloaded file and run Octave by using the Octave.bat
> file.  I didn't find any installation program.
>
> Okay, I _swear_ that yesterday this didn't work.. but as I've tried each of
> your examples I can't get my output to be the '1' or '0' that it was
> yesterday.
>
> I'm sorry to have bothered everyone.

No problem.

> Here is a follow-up question though.  Is there a way to get the result of
> that masking process to be output as a hex value?  Both to the terminal and
> when you do a range operation.

I showed you how in my previous reply with sprintf. You can use either
the dec2hex or sprintf functions to convert a number into a *string*
displaying the hexadecimal representation.

  >> sprintf ("0x%04X", bitand (0x55AA, 0xF0F0))
  ans = 0x50A0
  >> dec2hex (bitand (0x55AA, 0xF0F0))
  ans = 50A0

You could also use `format hex` and ensure that all of your variables
are integer types.

  >> format hex
  >> a = uint16 (0x55aa)
  a = 55aa
  >> b = uint16 (0xf0f0)
  b = f0f0
  >> bitand (a, b)
  ans = 50a0

I'm not sure what you mean by “output as a hex value…when you do a range
operation”.

--
mike


reply via email to

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