cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Number_Bases_Octal_Hex_Binary.mcdx

Steved3
1-Visitor

Number_Bases_Octal_Hex_Binary.mcdx

Will Prime MathCad ever get back to MathCad 15 strength?

12 REPLIES 12
Werner_E
25-Diamond I
(To:Steved3)

Given that we now have Prime 0.3 (PTC's spelling it as 3.0 must be a mistake) we can hope on Prime 1.0.

Is there any reason you are posting this as a document rather than as a question or a discussion?

Steved3
1-Visitor
(To:Steved3)

Yes, I thought it would be more useful to others (and quick and easy for me) to see where the impact (typical usage) might be.

If you use this stuff, you will miss it.  I use it alot, so I miss it very much (I have many 15.0 docs that now "dissappear" from my libary).

Also, maybe someone has written a "DLL" for the missing functions?

Questions or discussion seems pointless since Prime x.0 are released without the functions.

Werner_E
25-Diamond I
(To:Steved3)

I wish this would be the only feature missing, but ...

Werner_E
25-Diamond I
(To:Steved3)

The feature you demand can't be replaced by a user defined function in a DLL. And if you just are searching for simple functions that convert numbers of different bases - you won't need a DLL for that but can do directly in Mathcad. Examples can be found here in the forum. But of course none of these would be that natural and easy to use as what we had in Mathcad

I use it alot, so I miss it very much (I have many 15.0 docs that now "dissappear" from my libary).

Not here- its simply Prime which disappears (from the list of programs used for serious work) - better said, it never made it in that list.

Prime 3 sure is something which may be used for one task or another. But switching from MC15 to P3? No way!

Steved3
1-Visitor
(To:Steved3)

For sure its not the only feature misssing there are many others -  just think about formatting plots!

I've looked through the documentation to see how one might access a partial solution.  There are a couple of functions (num2str and str2num) that could help - BUT, I can't find how to make use of the format() function - there's no information on the format specifiers (I would have guessed it might be similar or exactly like C/C++ i.e. %n.nX etc).  The help files does claim you can do the conversions - however, that's the extent of the discussion in help.

I do believe a DLL can provide what's needed but you're right - not at all the best use compared to what already existed.  It's really mind boggling that it's been deprecated. 

We can convert into Prime this function (integer) http://twt.mpei.ac.ru/MCS/Worksheets/base2base.xmcd

Steved3
1-Visitor
(To:Steved3)

Yes Valery, I did find your xmcd on this site and I am using it - thank you very much

One issue with b2b - str2num() cannot account for non-digits. Therefore, conversion to any base[out] that produces a non-decimal-digit is an error. 

A new function 'str2int() would be required to solve the error.  It might look something like this C function:

"

// convert hex string to an integer

int 'str2int(char s[])
{
int i;
int n;

for (n=0,i=0; (isxdigit(s[i])&& i<8); i++)
{
  if ( s[i] >='0' && s[i] <='9')
    n = 0x10 * n + (s[i]-'0');
  else if ( s[i] >='a' && s[i] <='f')
   n = 0x10 * n + (s[i]-87);
  else if ( s[i] >='A' && s[i] <='F')
    n = 0x10 * n + (s[i]-55);
}
return (n);
}
"

For a floating point string, this gets maybe a different approach:

"

// Convert string to double

double str2dbl(char *s)
{ double dbl_data;
  sscanf(s,"%lf",&dbl_data); // str to double floating point number conversion
  return((dbl_data));
}

"

Werner_E
25-Diamond I
(To:Steved3)

One issue with b2b - str2num() cannot account for non-digits. Therefore, conversion to any base[out] that produces a non-decimal-digit is an error. 

Thats not true. The sheet Valery pointed to seems to work OK. You just have to use uppercase characters. Could it be that you tried lowercase ones? If not please specify what exactly is not working for you.

Now we are full in a discussion with some questions, too. Thats what I meant when I asked you in first place why you are placing this as a document. Documents usually are created to show something of value to other users, a worksheet which can be reused by others having library character. A sheet which is said not to work is not exactly in this catagory.

There may be a lot of other base to base conversion routines out there. So if you are still in need for one, why not open a discussion/question. Comments to documents are not listed in "Recent Contents" or the like and so are much harder to follow. Furthermore its not possible to attach files in comments.

Steved3
1-Visitor
(To:Steved3)

Sorry I was not clear.  Here's what I mean about produces an errror:

 

str2num("0123456789ABCDEF");

Give it a try?  Or not.  No need to do it again.

I believe that the document is of value to others - a worksheet that "cannot" be reused (yet).  It will eventually become "usable" once all the pieces are resolved.  I will then update it and post an updated document.  It was not my intention to get to any large scale full discussion - only very minimal discussion. I think we had that now.  However, it was worth replying to Valery since he was considerate in pointing out base2base. 

If there are any further conversion routines out there, I've not found them posted (I looked).

Werner_E
25-Diamond I
(To:Steved3)

STEVEN DESHAYES wrote:

                       

Sorry I was not clear.  Here's what I mean about produces an errror:

 

str2num("0123456789ABCDEF");

                   

Sure! It must throw an error as the string does not represent a valid (base10) number. So whats your problem with Valery's sheet?

Give it a try?  Or not.  No need to do it again.

Ahem? What??? Not sure what this should mean?

Werner_E
25-Diamond I
(To:Steved3)

If there are any further conversion routines out there, I've not found them posted (I looked).

                   

Maybe here, one year old: http://communities.ptc.com/message/192232#192232

I just posted an updated version here: http://communities.ptc.com/message/225923#225923

But again - no function can replace the different base representation we had in MC15 😞

Steved3
1-Visitor
(To:Steved3)

Thanks, I'll check it out.

No doubt about the latter comment !

Announcements

Top Tags