Gunnar Bittersmann: Frage zum Wiki-Artikel ‚JavaScript‘

Beitrag lesen

@@Der Martin

var stellen = Math.floor(Math.log(x) / Math.LN10) + 1;

Hach, dass die Leute immer gleich die fertige Lösung rausposaunen müssen!

Math.log(x) / Math.LN10 ist aber doch ein bisschen zu kompliziert; Math.log10(x) exitiert.

Wie gesagt: Für Werte kleiner 1 gilt das nicht mehr, aber das kratzt dich vermutlich nicht.

Vor allem für Werte kleiner 0 nicht. Und das dürfte kratzen. Das sollte man vorher abfangen.

LLAP 🖖

--
“You might believe there are benefits for the developer, but first of all, you should put those behind the interest of the user.” —Stefan Tilkov
Selfcode: sh:) fo:} ch:? rl:) br:> n4:& va:| de:> zu:} fl:{ ss:| ls:# js:|