3

I have N[Sqrt[2], 8] which outputs 0.4142136

How do I get the 4142136 part out of it? I tried RealDigits[N[Sqrt[2], 8] - Floor@Sqrt[2]][[1]] but because in the solution above the last digit was rounded up (0.41421356), it doesn't come out the same : {4, 1, 4, 2, 1, 3, 5}

Raksha
  • 633
  • 1
  • 6
  • 19
  • 1
    I would be helpful if you could add what you want to do with the result. Do you need an integer like 4142136 or a string "4142136" or is a list like your last output OK? – halirutan Feb 21 '15 at 03:30
  • halirutan, I want a list of digits or a number. In the end I need to add the digits after the decimal. – Raksha Feb 21 '15 at 03:33

2 Answers2

5
FractionalPart@N[Sqrt[2], 7] 10^7 // Round
(* 4142136*)
Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
  • That works, thanks :] I thought about doing it that way but for some reason decided that it wouldn't work for a large number of sig figs >.> ... but it totally does ... <.< – Raksha Feb 21 '15 at 03:38
4

A way to work with RealDigits, if desired:

Drop @@ RealDigits[Round[Sqrt[2], 1*^-7]] // FromDigits
4142136
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371