Decoding someone elses code what is this?

What does this “>>” mean? As in…

first_payment_in_series_date >> 3

I have never used this nor have i seen it before.

On Thu, Aug 25, 2011 at 1:12 PM, nate hunter [email protected]
wrote:

What does this “>>” mean? As in…

first_payment_in_series_date >> 3

I have never used this nor have i seen it before.

But you do know Ruby has documentation, right? :slight_smile:


Hassan S. ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan

means bit shift

eg

8 >> 3 means shift value by 3 bits to the right … result is 1 (8 =
1000b, after shift is 0001b = 1)

opposite is <<

1 << 3 = 8

tom

ps: in asm it is shl or shr

On Aug 25, 2011, at 22:12 , nate hunter wrote:

You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz

On Aug 25, 2011, at 4:54 PM, Tom M. wrote:

tom

ps: in asm it is shl or shr

If first_payment_in_series_date was an Integer, then that might be the
case, but I’d suspect that a Date is much more likely with that name.

Look for the documentation for Date#>>

-Rob

(posted so future readers will not be lead too far astray)


Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

.

Rob B. http://agileconsultingllc.com
[email protected]
+1 513-295-4739
Skype: rob.biedenharn

Yes i found it sorry for the trouble. There is so much crap in the code
I’m looking at I am having a hard time telling what is what. this can be
deleted!

On Aug 25, 9:54pm, Tom M. [email protected] wrote:

means bit shift

eg

8 >> 3 means shift value by 3 bits to the right … result is 1 (8 = 1000b, after
shift is 0001b = 1)

opposite is <<

1 << 3 = 8

Of course, being ruby it can mean different things on different
objects. For Date objects for example >> 3 advances the date by 3
months (and << moves in the other direction)

Fred

nate hunter wrote in post #1018531:

What does this “>>” mean? As in…

first_payment_in_series_date >> 3

I have never used this nor have i seen it before.

The first thing you should do is try to determine the type of the thing
calling the method. The method is ‘>>’ and the thing calling the method
is on the left. Because the programmer used good variable names, it
makes it easy to determine what type the left side is.

On Aug 25, 2011, at 23:33 , Rob B. wrote:

1 << 3 = 8

(posted so future readers will not be lead too far astray)

you’re right. When date, it moves by months, I’ve overlooked the _date
in variable name

tom

Posted via http://www.ruby-forum.com/.

Rob B. http://agileconsultingllc.com
[email protected]
+1 513-295-4739
Skype: rob.biedenharn


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz