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?
相关问题
- Extract matrix elements using a vector of column i
- Do the Java Integer and Double objects have unnece
- How do you get R's null and residual deviance
- How to display an image represented by three matri
- Is the conversion from '(signed) -1' to
相关文章
- 关于C#中 float、double、decimal 的运算不精确的问题。
- What is (INT32_MIN + 1) when int32_t is an extende
- How do I append metadata to an image in Matlab?
- How to convert hex string into decimal value
- How can I convert a OLE Automation Date value to a
- Convert HttpContent into byte[]
- Macro or function to construct a float (double) fr
- How can I write-protect the Matlab language?
You can just cast to an integer:
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 doThe functions You are looking for might be:
int8(number)
,int16(number)
,uint32(number)
Any of them will convert Double to an Integer, but You must pick the best one for the result You want to achieve. Remember that You cannot cast from Double to Integer without rounding the number.If I understood You correcly, You could create a function that would simply remove the "comma" from the Double number by multiplying your starting value by 2^n and then casting it to Integer using any of the functions mentioned earlier, performing whatever you want and then returning comma to its original position by dividing the number by 2^n
Multiplying the starting value by 2^n is a hack that will decrease the rounding error. The perfect value for n would be the number of digits after the comma if this number is relatively small.
Please also specify, why are You trying to do this? This doesn't seem to be the optimal solution.