1

Temat: Dziwne zachowanie RealDigits[]

Czy ktoś ma pomysł, dlaczego funkcja RealDigits[] zwraca nieoczekiwanie różniące się ilością cyfr znaczących wyniki? (proszę zwrócić uwagę na wynik dla liczby 1)

dla komórki z zawartością:

N[1, 20]
N[2, 20]
N[3, 20]
N[10, 20]
RealDigits[N[1, 20]]
RealDigits[N[2, 20]]
RealDigits[N[3, 20]]
RealDigits[N[10, 20]]

otrzymuję:

1.0000000000000000000
2.0000000000000000000
3.0000000000000000000
10.000000000000000000
{{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1}
{{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1}
{{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1}
{{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 2}

Ostatnio edytowany przez lootek (2009-10-21 13:28:22)

2

Odp: Dziwne zachowanie RealDigits[]

Ja dodam jeszcze 2 przykłady:

RealDigits[N[0.0, 2]]
RealDigits[N[0, 2]]
RealDigits[N[1, 2]]
RealDigits[N[2, 2]]
RealDigits[N[3, 2]]


{{0}, -307}

{{0}, 1}

{{1, 0, 0}, 1}

{{2, 0}, 1}

{{3, 0}, 1}

Zachowanie opisane w poście wyżej jest specyficzne dla podstawy 10. W systemie dwójkowym:

RealDigits[N[0.0, 2], 2]
RealDigits[N[0, 2], 2]
RealDigits[N[1, 2], 2]
RealDigits[N[2, 2], 2]
RealDigits[N[3, 2], 2]


{{0}, -1022}

{{0}, 1}

{{1, 0, 0, 0, 0, 0, 0}, 1}

{{1, 0, 0, 0, 0, 0, 0}, 2}

{{1, 1, 0, 0, 0, 0, 0}, 2}
Mathematica 7.0.1, Windows 7 64bit, 6 GB RAM

Odp: Dziwne zachowanie RealDigits[]

Mathematica 6 robi to samo.