ID:166942
![]() May 26 2006, 5:39 pm (Edited on May 26 2006, 7:07 pm)
|
|
How would I make Jave Script's parseInt(string, base) function in to a DM proc?
|
![]() May 26 2006, 9:58 pm
|
|
Depends, what does it do?
|
text2num() doesn't do base conversions though.
If you want base conversion you'll have to write the algorithm yourself. A web search will turn up ways of doing it; you'll have to adapt them to DM, but that shouldn't be hard provided you understand it all. |
Ah, he's looking for base conversions?
The basic idea is pretty simple: Numbers can be represented as follows: n=x*b**0 + y*b**1 + z*b**2... Where x, y and z are the digits. For example, 642, in decimal, is 6*10**2 + 4*10**1 + 2*10**0. That number b (10, in this case) is the base. So converting between binary and decimal is just a matter of converting x*10**0 + y*10**1 + z*10**0... into x*2**0 + y*2**1 + z*2**2... Which isn't all that difficult. |
Can some body please convert this to DM.
public static int parseInt(String s, int radix) |