| Author |
Message |
angu
Joined: 05 Nov 2007 Posts: 60 Helped: 4
|
08 Apr 2008 3:51 decimal to binary conversion |
|
|
|
Hi........
I want to convert decimal numbers to binary form in MATLAB.. I used dec2bin(d,k) function to convert it. But it only supprts for numbers less than 2^53. I want conversion for numbers upto 2^64.
I needed this as a part of my project.....So please help me.....or give me any hints.......... please.
Thanks in advance
Angu
|
|
| Back to top |
|
 |
muralicrl
Joined: 06 Feb 2008 Posts: 278 Helped: 30
|
08 Apr 2008 4:51 Re: decimal to binary conversion |
|
|
|
Hi,
if u use dec2bin(D), where D as a string and it can represent upto 2^52 only. U can't go more than that.
Added after 2 minutes:
Hi,
Matlab can represent an integer upto 2^52 in any base format.
|
|
| Back to top |
|
 |
flanello
Joined: 09 Jan 2008 Posts: 57 Helped: 4
|
09 Apr 2008 9:54 Re: decimal to binary conversion |
|
|
|
| Perhaps it is possible to program the conversasion by hand?
|
|
| Back to top |
|
 |
angu
Joined: 05 Nov 2007 Posts: 60 Helped: 4
|
09 Apr 2008 17:47 Re: decimal to binary conversion |
|
|
|
hi flanello
thank u for ur efforts..
I tried to implement our hand-division method for dec-binary conversion..
but for numbers greater than 2^53 - 1, arithmetic operations wont support........so we cannot do division or modulo division...
If u have any other way to solve this pblm, pls help me
thank u
|
|
| Back to top |
|
 |
flanello
Joined: 09 Jan 2008 Posts: 57 Helped: 4
|
10 Apr 2008 8:47 Re: decimal to binary conversion |
|
|
|
Unfortunately I haven’t matlab available at the moment…..
What operations can you do in matlab with number greater than 2^53 - 1?
Because if you can subtract, you can build your own divison/modulo function with a simple loop.
I now this is not a performant solution....
But I have no better idea at the moment
Added after 11 minutes:
If the handcoded functions works, you can use these functions for the first bits until the remaining number is smaller than 2^53. Then you can use the dec2bin function from matlab.
|
|
| Back to top |
|
 |
The_Unknown
Joined: 20 Apr 2008 Posts: 1
|
20 Apr 2008 3:15 Re: decimal to binary conversion |
|
|
|
| I made a exel spreadsheet a while back to convert binary to decimal and vica versa. At the moment it only extends to 1024. If you still neeed something like this let me know, and I'll extend to whatever it was you required.
|
|
| Back to top |
|
 |
RBB
Joined: 02 Jul 2007 Posts: 49 Helped: 3
|
20 Apr 2008 3:43 decimal to binary conversion |
|
|
|
| It sounds like if Matlab doesn't support decimal numbers greater than 2^53, you may need to create a custom data type & the appropriate conversion function.
|
|
| Back to top |
|
 |