On Wed, Jun 17, 2015 at 6:25 AM, Benedikt Ritter <brit...@apache.org> wrote:

> 2015-06-17 14:03 GMT+02:00 David Blevins <david.blev...@gmail.com>:
>
> > I'd be happy to donate these if we want them:
> >
> >
> >
> https://raw.githubusercontent.com/tomitribe/tomitribe-util/master/src/main/java/org/tomitribe/util/SizeUnit.java
> >
> >
> https://raw.githubusercontent.com/tomitribe/tomitribe-util/master/src/test/java/org/tomitribe/util/SizeUnitTest.java
> >
> > Which commons lib would these go in?  (can send a patch)
> >
>
> Very nice! We would add this to Commons IO. You can contribute via github,
> if you like [1]. There are a few things to take into account imho:
>
> - Differenciate between decimal and binary prefixes, e.g. 1 Megabyte = 1000
> Kilobyte, but 1 Mebibyte = 1024 Kibibyte. Not sure whether this is really
> that important.
>

If we were to do only one I would do the base 2 case. But I can see
offering a second enum for base 10.

Gary

- Petta, Exa, Zetta and Yotta prefixes are missing. At least Petta my
> become important soon.
> - What about translations to bits? For example band width are often
> calculated in Mega Bits/sec
> - What about overflows when translating for example Exabytes to Bytes? The
> result won't fit into a long.
>
> I've also put an enum together but without translation logic, because of
> the overflow problem [2]. Maybe the implementations can be merged some how?
>
> Benedikt
>
> [1] https://github.com/apache/commons-io
> [2]
>
> https://issues.apache.org/jira/secure/attachment/12694350/IO-294_FileSizeUnit.patch
>
>
> >
> >
> > -David
> >
> > On Wed, Jun 17, 2015 at 8:50 AM, Gary Gregory <garydgreg...@gmail.com>
> > wrote:
> >
> > > Hi All:
> > >
> > > Java 5 introduced TimeUnit, a very nice enum.
> > >
> > > What do you all think of a ByteSizeUnit enum to handle bit, nibble,
> byte,
> > > kilobyte, kilobit, megabyte and so on?
> > >
> > > Gary
> > >
> > > --
> > > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > > Java Persistence with Hibernate, Second Edition
> > > <http://www.manning.com/bauer3/>
> > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > > Spring Batch in Action <http://www.manning.com/templier/>
> > > Blog: http://garygregory.wordpress.com
> > > Home: http://garygregory.com/
> > > Tweet! http://twitter.com/GaryGregory
> > >
> >
>
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>



-- 
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to