[R] tried half-precision but "size 2 is unknown on this machine"

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Sun Jan 4 17:25:47 CET 2015

Sorry about the dead lead on the package... it is hexView.  It does not support FP16 directly though... You would have to find another way to make that conversion. Some people have posted code that may be usable with Rcpp [1]. I believe your architecture may support hardware conversion of FP32 to FP16. If you came up with a portable version, I imagine that would be a nice contribution to make to hexView.

[1] https://fgiesen.wordpress.com/2012/03/28/half-to-float-done-quic/
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
Sent from my phone. Please excuse my brevity.

On January 3, 2015 11:03:19 PM PST, Mike Miller <mbmiller+l at gmail.com> wrote:
>Thanks for the pedantic insult, but no thanks.  I'd rather just hear if
>anyone reading this is able to make something like this work on any 
>vec <- 1:10/10
>con <- file( "test.bin16", "wb" )
>writeBin( vec , con, size=2 )
>If they can do it, they can tell me about it.  That shouldn't ruin the 
>list for anyone else.
>I can understand why a machine architecture would prevent
>operations with half-precision numbers, but I can't understand how it 
>prevents us from encoding doubles as half-precision to store them in a 
>file.  They could then be read back in, translated on the fly into 
>doubles.  Like I said, I've been using integers instead of floats to
>the numbers in files, but it could be slightly more convenient to use 
>half-precision floats for storage instead of converting integers to 
>Almost forgot.  Please tell me how this changes anything:
>> sessionInfo()
>R version 3.1.1 (2014-07-10)
>Platform: x86_64-unknown-linux-gnu (64-bit)
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C 
>LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C 
>attached base packages:
>[1] stats     graphics  grDevices utils     datasets  methods   base
>loaded via a namespace (and not attached):
>[1] tools_3.1.1
>Also, this is how the hexbin package is described:
>"Description" Binning and plotting functions for hexagonal bins."
>So I guess that suggestion wasn't helping me much, either.
>On Sat, 3 Jan 2015, Jeff Newmiller wrote:
>> Your message is missing either a reproducible example or an
>> of your R environment (such as the output of sessionInfo()).
>> Yes, the machine architecture can prevent certain types of
>> This is however a poor venue for discussing such issues.
>> I suggest that you investigate the hexbin package for binary data 
>> handling, and if you still have issues then post again, following the
>> posting guide recommendations.
>> Jeff Newmiller                        The     .....       .....  Go
>> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
>>                                      Live:   OO#.. Dead: OO#.. 
>> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
>> /Software/Embedded Controllers)               .OO#.       .OO#. 
>> Sent from my phone. Please excuse my brevity.
>> On January 3, 2015 9:31:02 PM PST, Mike Miller <mbmiller+l at gmail.com>
>>> It's an IEEE standard format:
>>> This is what I see:
>>>> writeBin(vec , con, size=2 )
>>> Error in writeBin(vec, con, size = 2) : size 2 is unknown on this
>>> machine
>>> I'm not sure what the machine has to do with it.  It's really up to
>>> software, isn't it?
>>> Is there a way to get R to read/write half-precision numbers
>>> (binary16)?
>>> It isn't a big deal for me because unsigned 16-bit integers are
>>> well enough, but I'd like to have an answer for people who ask why I
>>> make
>>> them divide by 1000 all the time.  ;-)
>>> Mike
>>> ______________________________________________
>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list