2
$\begingroup$

Given 0.4, the binary form is 0.0110011001(with 10 digits after ".") and 0.011001100110011001100110(with 24 digits after ".") without rounding. Is there any function that can do such converting? The BaseForm does not have option to define the digit number. What I did is to use RealDigits to extract all the needed digits and convert with PadRight and StringJoin. But this is a very lengthy and ineffective way.

$\endgroup$
0

1 Answer 1

4
$\begingroup$
d = 10; N[FromDigits[RealDigits[.4, 2, d, -1]], d - 1] (* 0.0110011001 *) d = 24; N[FromDigits[RealDigits[.4, 2, d, -1]], d - 1] (* 0.011001100110011001100110 *) 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.