PHP :: Aufgabe #168 :: Lösung #3
5 Lösungen

#168
Zahlen umwandeln: Binär zu Dezimal
Anfänger - PHP
von Nachbar
- 13.09.2017 um 14:19 Uhr
Schreibe eine Funktion, die Zahlen aus dem Dualsystem in Zahlen des Dezimalsystems umwandelt.
Beispiel:
Binär: 11010
Dezimal: 26
Beispiel:
Binär: 11010
Dezimal: 26
#3

von habablab (270 Punkte)
- 22.02.2018 um 18:12 Uhr

<?php $sInput = "11010"; $iOutput = 0; $aInput = str_split ( $sInput, 1 ); foreach ($aInput as $row) { $iOutput = $iOutput * 2 + $row; } echo ($iOutput);
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1