21
$\begingroup$

I believe Internal`StringToDouble was the only way to fast convert string into numbers. Now in V12.3 it was removed:

Internal`StringToDouble["1"]

Internal`StringToDouble["1"]

As long as it's broken other options than (the slow) ToExpression?

UPDATED

Check the accepted answer. There are new functions to do that in V12.3

$\endgroup$
5
  • 4
    $\begingroup$ Does Internal`StringToMReal do it for you? $\endgroup$
    – Carl Lange
    May 21, 2021 at 21:02
  • 1
    $\begingroup$ @CarlLange literally just found that (from XMPTools`Helpers`Private`stringToReal). BTW it looks like Internal`StringToDouble and its counterpart still exist but have had their defs. removed per System`Private`HasAnyCodesQ $\endgroup$
    – b3m2a1
    May 21, 2021 at 21:03
  • $\begingroup$ In v12.3 there also appears to be a problem with Internal`DoubleToString $\endgroup$
    – Bob Hanlon
    May 21, 2021 at 21:06
  • $\begingroup$ @CarlLange tks. I believe It can help for now. $\endgroup$
    – Murta
    May 21, 2021 at 22:03
  • 1
    $\begingroup$ @BobHanlon that's now MRealToString $\endgroup$
    – b3m2a1
    May 22, 2021 at 23:24

1 Answer 1

29
$\begingroup$

StringToDouble was renamed StringToMReal as part of code cleanup and the addition of several friends:

 ?Internal`StringTo*
 (*Internal`StringToBoolean   Internal`StringToMInteger
   Internal`StringToMReal     Internal`StringToMRational*)

It should be as fast, but now in failure cases it returns a proper Failure object instead of some bizarro-$Failed[_String]. The error checking could be tighter (the new functions are more discriminating), but at least for now it will just truncate when it encounters invalid characters like the old StringToDouble. Note that the M in the names is for "Machine". There shouldn't be an Internal`StringToDouble, and I don't see it in a clean, standalone kernel. So perhaps some paclet that is multi-version is referencing and creating it.

$\endgroup$
7
  • $\begingroup$ Curiously, Internal`StringToDouble shows up on wolfram cloud, but does not work. $\endgroup$ May 22, 2021 at 7:09
  • $\begingroup$ What about Internal`DoubleToString? It is still here but lost its definition and stays unevaluated. Bug? $\endgroup$
    – Philipp
    May 22, 2021 at 10:50
  • $\begingroup$ @Philipp that's now MRealToString $\endgroup$
    – b3m2a1
    May 22, 2021 at 23:24
  • $\begingroup$ @b3m2a1: Thank you very much. Now I feel stupid because I was looking for RealToString and similar. $\endgroup$
    – Philipp
    May 23, 2021 at 5:04
  • 2
    $\begingroup$ @Itai Seggev: Evaluating Internal`MRealToString in a clean kernel creates Internal`StringToDouble again which seems wrong. $\endgroup$
    – Philipp
    May 23, 2021 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.