Link to home
Create AccountLog in
Hardware

Hardware

--

Questions

--

Followers

Top Experts

Avatar of kuntilanak
kuntilanak🇺🇸

test if a number is greater than 0
if I have a 32 bit number in MIPS, I want to extract the sign bit of that number (0 or 1). How can I do this using logical operators? I want the end result either to be 0 or 1.

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


ASKER CERTIFIED SOLUTION
Avatar of d-glitchd-glitch🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of kuntilanakkuntilanak🇺🇸

ASKER

yes, it's two's complement and it has a sign bit as well.. at position 31...

how do I extract this 31 bit and put it to one bit variable called result?

Avatar of kuntilanakkuntilanak🇺🇸

ASKER

does shifting the 32 bit two's complement 31 times work?

Avatar of d-glitchd-glitch🇺🇸

Depends on how the shift is implemented.  There may be more than one type of shift available.

I don't know if they shift in 1's, 0's, or copies of the MSB

A circular shift 1-bit to the right and anding the 31 MSB with 0's could work too.

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of kuntilanakkuntilanak🇺🇸

ASKER

the shift add's 0 to the MSB...

Avatar of kuntilanakkuntilanak🇺🇸

ASKER

it's verilog(VHDL) right shift if you are familiar with

Avatar of d-glitchd-glitch🇺🇸

I am not too familiar with VHDL yet, but you certainly have direct access to individual bits.

You should be able to say sometihing like

     Result =  !Number[31]      where    ! is negation      and   [31] is the index.


Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of kuntilanakkuntilanak🇺🇸

ASKER

what if I want to know if a 32 bit is greater than 0? the above is for greater or equal than 0... any easy way to do this?

SOLUTION
Avatar of TursilionTursilion🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Hardware

Hardware

--

Questions

--

Followers

Top Experts

Hardware includes cell phones and other digital living devices, tablets, computers, servers, peripherals and components, printers and scanners, gaming consoles, networking hardware such as routers, hubs, switches and modems, storage devices and security equipment such as firewalls and other appliances.