Coder Social home page Coder Social logo

Comments (6)

marcandre avatar marcandre commented on June 1, 2024

Fixed two problems with float packing unpacking. One was with native endian, double precision (was using 'F', now uses 'D') and that packing in single precision made all subsequent packing single precision (even if double precision was requested).

If this hasn't fixed your issue, please let me know!

Thanks

from packable.

translunar avatar translunar commented on June 1, 2024

Hmm. Still seems to not quite be working for me. I have to add :endian => :little to the options, though unpack('D') works fine for me.

from packable.

marcandre avatar marcandre commented on June 1, 2024

Mmmm, here's what I have on my end:

$ irb
1.9.3p194 :001 > require 'packable'
 => true 
1.9.3p194 :002 > 1.1.pack(:double)
 => "?\xF1\x99\x99\x99\x99\x99\x9A" 
1.9.3p194 :003 > Packable::VERSION
 => "1.3.5" 
1.9.3p194 :005 > `ruby -v`
 => "ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10.8.0]\n" 

What's on your end?

from packable.

translunar avatar translunar commented on June 1, 2024

I get the same thing, but 1.1.pack(:double) is not doing :endian => :native, as far as I can tell.

1.1.pack(:double)
  => "?\xF1\x99\x99\x99\x99\x99\x9A"
1.1.pack('E')
  => "\x9A\x99\x99\x99\x99\x99\xF1?"
1.1.pack('D')
  => "\x9A\x99\x99\x99\x99\x99\xF1?"
1.1.pack(:precision => :double, :endian => :native)
  => "\x9A\x99\x99\x99\x99\x99\xF1?"

from packable.

marcandre avatar marcandre commented on June 1, 2024

Indeed, the default is :endian => :big, not sure why I chose that at the time. I'll close this issue, then, since you can adjust the settings or specify the endianness you want, things work.

Or let me know what you'd like to be done!

from packable.

translunar avatar translunar commented on June 1, 2024

It just seems like it makes more sense to use whatever the native setting is.

from packable.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.