# How to get string from the result of BaseForm function

I want to get the string "b0.3ae"

In:=BaseForm[176.23, 16]
Out:=Subscript[b0.3ae, 16]


And then I want to get 176.23 by FromDigits["b0.3ae", 16] operation.

But I can't do this very well.

We also need to consider the case of this scientific counting method:

BaseForm[10045.21^6, 16]


fromBaseForm = RawBoxes[ToBoxes[#] /. SubscriptBox[a_, _] :> a]&;


Examples:

fromBaseForm @ BaseForm[176.23,16]


"b0.3ae"

fromBaseForm @ BaseForm[10045.21^6,16]


"d.9915"*16^("19")

(BaseForm[176.23, 16] // ToString // StringSplit)[[1]]


yields

"b0.3ae"


which seems to be what you want.

It isn't clear what you want in the second case. A similar technique should work, though.

• But this operation is not valid for (BaseForm[10045.21^6, 16] // ToString // StringSplit) – Please Correct GrammarMistakes Jan 21 at 1:28
• Yes. StringSplit yields four strings for that case (decimal exponent, hexadecimal mantissa, and two copies of "16"). You can use them as you wish, but you haven't stated what output you want, so I can't write the code. – John Doty Jan 21 at 1:38
• I want string results in the form of "d.9915" <> "\[Times]" <> ToString[Defer[16^19], FormatType -> StandardForm] – Please Correct GrammarMistakes Jan 21 at 1:51

I did it like this, but it's too complicated :

#[[1]] <>
If[Length[#] > 5, ToString[("\[Times]16")^#[[4]], StandardForm],
""] &@StringCases[
ToString[BaseForm[10045.21^6, 16],
StandardForm], (WordCharacter ... ~~ "." ~~
WordCharacter ...) | (DigitCharacter ..)]