# 0xff000000

**URL:** <https://www.ruby-forum.com/t/0xff000000/83871>\
**Category:** Ruby\
**Created:** [January 30, 2007, 11:41am UTC](https://www.ruby-forum.com/t/0xff000000/83871 "2007-01-30T11:41:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SonOfLilit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@SonOfLilit](https://www.ruby-forum.com/u/SonOfLilit)\
**Post date:** [January 30, 2007, 11:41am UTC](https://www.ruby-forum.com/t/0xff000000/83871/1 "2007-01-30T11:41:46Z")

</div>

Hello.

I am running on a 32 bit machine.

I need to pass SDL the unsigned long 0xff000000 as a mask.

s = SDL::Surface.new\_from(image\_data, screen.w, screen.h, 32,  
screen.w\*4,  
0x00ff0000, 0x0000ff00, 0x000000ff,  
0xff0000000)

fails with “bignum too big to convert into `unsigned long’ (RangeError)”

which is very understandable, considering that Ruby uses the MSB of a  
VALUE  
and thus Fixnums can only be 31bit on 32bit machines.

What’s the best idiom to get the mask so I can pass it?

Thanks,

Aur

---

<div class="post-metadata">

**Author:** ![SonOfLilit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@SonOfLilit](https://www.ruby-forum.com/u/SonOfLilit)\
**Post date:** [January 30, 2007, 12:25pm UTC](https://www.ruby-forum.com/t/0xff000000/83871/2 "2007-01-30T12:25:53Z")

</div>

Looking at the ruby source showed me that ruby /can/ translate  
0xff000000 to  
a ulong.

The problem was a typo in my code, one extra 0.

Aur S.

---

<div class="post-metadata">

**Author:** ![SonOfLilit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@SonOfLilit](https://www.ruby-forum.com/u/SonOfLilit)\
**Post date:** [January 30, 2007, 12:26pm UTC](https://www.ruby-forum.com/t/0xff000000/83871/3 "2007-01-30T12:26:54Z")

</div>

On 1/30/07, SonOfLilit [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> which is very understandable, considering that Ruby uses the MSB of a VALUE  
> and thus Fixnums can only be 31bit on 32bit machines.
> 
> What’s the best idiom to get the mask so I can pass it?
> 
> Thanks,
> 
> Aur

The number 0xff0000000 in your code has seven zeroes instead of six,  
so it’s too big to fit in 32 bits.
