Skip to content

Commit cc9eedb

Browse files
committed
Update readme
1 parent 02b330b commit cc9eedb

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

README.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# php-filesize
55

6-
A flexible library for calculating binary file sizes and converting between units.
6+
A flexible library for calculating file sizes and converting between units.
77

88
### Installation
99

@@ -15,7 +15,7 @@ $ composer require chrisullyott/php-filesize
1515

1616
### Instantiate
1717

18-
A `FileSize` object, both on creation and within its methods, understands just about any expression of data size in bytes. You may instantiate it with a size, or leave it initially empty.
18+
A `FileSize` object, both on creation and within its methods, understands just about any expression of data size. You may instantiate it with a size, or leave it initially empty.
1919

2020
```php
2121
use ChrisUllyott\FileSize;
@@ -59,10 +59,15 @@ $size->add('2G')
5959
echo $size->asAuto(); // '10.00 GB'
6060
```
6161

62-
### Details
62+
### Number base
6363

64-
- Since this is in binary, remember that `500 MB` translates to `0.49 GB` and not exactly `0.5 GB` as you'd expect in the less accurate decimal system. See [Wikipedia](https://en.wikipedia.org/wiki/Binary_prefix).
65-
- Exporting bytes returns an `int`, otherwise a `float`.
64+
The second argument of the constructor is the number base, which accepts either `2` (binary) or `10` (decimal). We use binary by default. To handle sizes in decimal:
65+
66+
```php
67+
$size = new FileSize(10921134, 10);
68+
69+
echo $size->asAuto(); // '10.92 MB'
70+
```
6671

6772
### Contribute
6873

0 commit comments

Comments
 (0)