help-octave
[Top][All Lists]
Advanced

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

Re: Masking using Hexadecimal Values


From: Mike Miller
Subject: Re: Masking using Hexadecimal Values
Date: Thu, 4 Aug 2016 09:37:25 -0700
User-agent: Mutt/1.6.2-neo (2016-07-23)

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]