How to use Bitxor for Double Numbers?

后端 未结 2 420
攒了一身酷
攒了一身酷 2021-01-29 08:16

I want to use xor for my double numbers in matlab,but bitxor is only working for int numbers. Is there a function that could convert double to int in Matlab?

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 09:01

    You can just cast to an integer:

    a = 1.003
    
    int8(a)
    
    ans =
    
    1
    

    That gives you an 8 bit signed integer, you can also get other size i.e. int16 or else unsigned i.e. uint8 depending on what you want to do

提交回复
热议问题