-1

i suspect this is a rather simple question to some of you, however i'm a self-taught guy and have no clue what the thing below is all about. So i'm sorry if this is regarded as a stupid question :) (may it be a duplicate or simply a question unfit for this community)

i was looking for a clean way to display filesize in a human readable format and i stumbled upon this answer:

Human readable filesize

the thing is, i've never seen that syntax of 1<<30 being used before.

i've tried to google on the subject, but i simply do not know how to 'search' for it.. no clue how the syntax is called.

I'm not really looking for a full blown reply explaining every detail. I'll do the research myself :-) however i'd greatly appreciate anyone pointing me in the right direction.

thanks

Community
  • 1
  • 1
Bodybag
  • 308
  • 2
  • 11
  • 1
    It's called a [bitwise operator](http://www.php.net/manual/en/language.operators.bitwise.php). – Korikulum Jun 02 '14 at 11:51
  • 1
    That thing is called Bitshift http://www.php.net/manual/en/language.operators.bitwise.php – Jite Jun 02 '14 at 11:52
  • hell yea, ty for that reference, whoever edited my question :-) that's a bookmark! :D, that's more than i could ask for, so you can close this for my part. (or do i do that myself? :p) – Bodybag Jun 02 '14 at 11:55

1 Answers1

2

Hi this are Bitwise Operators. Bitwise operators allow evaluation and manipulation of specific bits within an integer.

Bitwise Operators
Example Name    Result
$a & $b And Bits that are set in both $a and $b are set.
$a | $b Or (inclusive or)   Bits that are set in either $a or $b are set.
$a ^ $b Xor (exclusive or)   Bits that are set in $a or $b but not both are set.
~ $a    Not  Bits that are set in $a are not set, and vice versa.
$a << $b    Shift left   Shift the bits of $a $b steps to the left (each step means "multiply by two")
$a >> $b    Shift right  Shift the bits of $a $b steps to the right (each step means "divide by two")

More more information go to http://www.php.net/manual/en/language.operators.bitwise.php

shabeer
  • 1,016
  • 9
  • 16