21

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

matrix42
  • 6,996
  • 2
  • 26
  • 62
Murta
  • 26,275
  • 6
  • 76
  • 166

1 Answers1

31

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.

John Fultz
  • 12,581
  • 58
  • 73
Itai Seggev
  • 14,113
  • 60
  • 84
  • Curiously, Internal`StringToDouble shows up on wolfram cloud, but does not work. – CA Trevillian May 22 '21 at 07:09
  • What about Internal`DoubleToString? It is still here but lost its definition and stays unevaluated. Bug? – Philipp May 22 '21 at 10:50
  • @Philipp that's now MRealToString – b3m2a1 May 22 '21 at 23:24
  • @b3m2a1: Thank you very much. Now I feel stupid because I was looking for RealToString and similar. – Philipp May 23 '21 at 05:04
  • 2
    @Itai Seggev: Evaluating Internal`MRealToString in a clean kernel creates Internal`StringToDouble again which seems wrong. – Philipp May 23 '21 at 05:23
  • The Google Calendar interface uses InternalStringToDouble for TimeZone specifications, returning things like DateObject["1954-12-03T22:55:00", TimeZone -> InternalStringToDouble["+01"]] Obviously this was not updated for V12.3. All my applications are broken. Is there a fix? – John Jowett Jul 28 '21 at 20:45
  • As a workaround until this is fixed, you could wrap your code in a Block like: Block[{Internal`StringToDouble = Internal`StringToMReal}, ServiceExecute[...]] - or just make the definition globally: Internal`StringToDouble = Internal`StringToMReal – Jesse Friedman Jul 28 '21 at 22:04