Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP: Umwandlung von Scientific Notation

Empfohlene Antworten

Veröffentlicht

Servus :)

hab da n Problemchen:

Ich habe eine Funktion die einen Wert (muesste float sein) bekommt, den umwandelt und einen String zurueckgibt.

Leider bekommt man ab einen bestimmten groesse des Eingangswertes das ganze als Scientific Notation dargestellt, was net so angenehm ist :(

Was ich braeuchte is eine Umwandlung, der ich den Eingangswert geben und einen String als "echte" Zahl zurueck bekomme.

1.111111E+12 = 1111111000000 (oder so aehnlich)

Helft mir :)

Und hier die Loesung des Ganzen:

        $suche="E";
$strlen_ex = strlen($money);
if (stristr($money, $suche))
{
$exponent=substr($money,-2);
$search_position=$strlen_ex - 4;
$money_wo_ex=substr($money,0,$search_position);
$money_wo_ex_len=strlen($money_wo_ex);
$money_wo_komma=substr($money_wo_ex,0,1) . substr($money_wo_ex,2,$money_wo_ex_len-2);
if (strlen($money_wo_komma) < (1 + $exponent))
{
$reallen=1+$exponent;
$missing=$reallen-strlen($money_wo_komma);
for ($j=0; ($j < $missing); $j++)
{
$money_wo_komma .= "0";
}
}
$money=$money_wo_komma;
}[/php]

Ob das nun die Sauberste Loesung is, lasse ich mal dahingestellt ;)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.