0
a='Z'
if ('A'<a<'Z'):
print(a.lower())

blt and bgt cant do both of them at the same time because once the condition is met for blt it will branch no matter what of the other condition

blt $t0,'Z',cond \n bgt $t0,'A',cond

Rama Zain
  • 5
  • 3
  • `if (a - ('A' + 1)) < ('Z' - ('A' + 1))` Note this implements what you wrote, probably not what you meant. See my next comment. – prl Aug 13 '23 at 13:03
  • You probably want `if ('A' <= a <= 'Z')`, no? So transform it into `if (a - 'A') < ('Z' - 'A' + 1)`. The comparison has to be an unsigned comparison. This takes advantage of unsigned wraparound, so a value of `a` less than 'A' wraps to a large number and fails the test. – prl Aug 13 '23 at 13:06
  • 2
    Basically a duplicate of [How can I implement if(x >= '0' && x <= '9') range checks like isdigit in MIPS?](https://stackoverflow.com/q/55408890) , and also [Testing if a value is within one of two ranges](https://stackoverflow.com/a/66893955) for an efficient range check using `addiu` / `sltiu` / `bnez` like @prl mentioned. – Peter Cordes Aug 13 '23 at 16:21

0 Answers0