Murphy's World @ homeserver holyghost alias dyndns.murphys-world.de | ||||||||||||||||||||||||||||||||||||||
| START
Projekt Murphy's CMSmini
JavaScript TIPPS & TRICKS
GeoCaching
NEWS
TERMINE
FUNSTUFF
LINKS
VIP-BEREICH
KONTAKT
IMPRESSUM
|
JavaScript Tipps & Tricks |
|||||||||||||||||||||||||||||||||||||
| Dezimalpräfixe pseudo-SI-konform | prozentualer Unterschied | Binärpräfixe IEC-konform |
||
|---|---|---|---|---|
| Name (Symbol) | Bedeutung | gerundet | Name (Symbol) | Bedeutung |
| Kilobyte (KB) | 103 Byte = 1.000 Byte | 2,40% | Kibibyte (KiB) | 210 Byte = 1.024 Byte |
| Megabyte (MB) | 106 Byte = 1.000.000 Byte | 4,86% | Mebibyte (MiB) | 220 Byte = 1.048 576 Byte |
| Gigabyte (GB) | 109 Byte = 1.000.000.000 Byte | 7,37% | Gibibyte (GiB) | 230 Byte = 1.073.741 824 Byte |
| Terabyte (TB) | 1012 Byte = 1.000.000.000.000 Byte | 9,95% | Tebibyte (TiB) | 240 Byte = 1.099.511.627.776 Byte |
| Petabyte (PB) | 1015 Byte = 1.000.000.000.000.000 Byte | 12,6% | Pebibyte (PiB) | 250 Byte = 1.125.899.906.842.624 Byte |
Quelle: http://de.wikipedia.org/wiki/Byte
string byteunit2 ( integer size )
string byteunit10 ( integer size )
| size | = die umzurechnende Speichergröße |
function byteunit2(s) {
r=
(s>1048523571?(s/1073741824).toFixed(1)+' GiB':
(s>1023948?(s/1048576).toFixed(1)+' MiB':
(s>999?(s/1024).toFixed(1)+' KiB':s+' B')));
return r.replace(/\./g,',');
}
function byteunit10(s) {
r=
(s>999949999?(s/1000000000).toFixed(1)+' GB':
(s>999949?(s/1000000).toFixed(1)+' MB':
(s>999?(s/1000).toFixed(1)+' KB':s+' B')));
return r.replace(/\./g,',');
}
<script type="text/javascript"> alert ( byteunit2 ( 30141 ) + " ~ " + byteunit10 ( 30141 ) + "\n" +
byteunit2 ( 1759076 ) + " ~ " + byteunit10 ( 1759076 ) ); </script>
29,4 KiB ~ 30,1 KB
1,7 MiB ~ 1,8 MB
Die auf dieser Seite notierten Scripte byteunit2() und byteunit10() sind Public Domain.
Zurück zur JavaScript Funktionsübersicht
© 2026 Murphy's World Alle Rechte vorbehalten Impressum