# Blobs

**URL:** <https://www.ruby-forum.com/t/blobs/109549>\
**Category:** Rails\
**Created:** [July 16, 2007, 7:27pm UTC](https://www.ruby-forum.com/t/blobs/109549 "2007-07-16T19:27:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![perskog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e47c2d/32.png) [@perskog](https://www.ruby-forum.com/u/perskog)\
**Post date:** [July 16, 2007, 7:27pm UTC](https://www.ruby-forum.com/t/blobs/109549/1 "2007-07-16T19:27:58Z")

</div>

Hi@All!

I completely new to RoR.

I have a table which looks like this:  
[id | width:int | height:int | data: blob]

The blob contains a matrix of double precision values (64 bits).  
Apparently RoR gives me a string when i read the blob. How do I convert  
this string to a double matrix? Or rather, how do I turn 4 bytes into a  
Float?

Thanks,  
Par

---

<div class="post-metadata">

**Author:** ![perskog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e47c2d/32.png) [@perskog](https://www.ruby-forum.com/u/perskog)\
**Post date:** [July 17, 2007, 12:16pm UTC](https://www.ruby-forum.com/t/blobs/109549/2 "2007-07-17T12:16:47Z")

</div>

Pete Y. wrote:

> Par Skoglund wrote:
> 
> > Or rather, how do I turn 4 bytes into a  
> > Float?
> 
> You probably want to look at String.unpack and its opposite Array.pack.
> 
> Pete Y.  
> [http://notahat.com/](http://notahat.com/)

upack did the trick.

Thanks a million, Pete!

---

<div class="post-metadata">

**Author:** ![perskog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e47c2d/32.png) [@perskog](https://www.ruby-forum.com/u/perskog)\
**Post date:** [July 17, 2007, 7:08am UTC](https://www.ruby-forum.com/t/blobs/109549/3 "2007-07-17T07:08:55Z")

</div>

Par Skoglund wrote:

> Or rather, how do I turn 4 bytes into a  
> Float?

You probably want to look at String.unpack and its opposite Array.pack.

Pete Y.

> **[Pete Yandell — Principal Engineer / Architect](https://notahat.com/)**
>
> Pete Yandell is an experienced Principal Software Engineer and Architect based in Melbourne, Australia.
