Results 1 to 5 of 5

Thread: Fun Facts, collect :>

  1. #1
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts

    Fun Facts, collect :>

    If you shift a number with $number<<20, it's multiplied by 1024*1024. That's useful to convert MB into Bytes:

    Code:
    megabytes = 256;
    bytes = megabytes << 20;
    timescale 0.01

  2. #2
    ... connecting woodchop146's Avatar
    Join Date
    Aug 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your explanation is kinda bad.
    Are you just trying to say that the operator << 20 will multiply by 1024?

  3. #3
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Bytes into Kilobytes:
    256 << 10 == 256 * 1024
    Bytes into Megabytes:
    256 << 20 == 256 * 1024 * 1024


    One shift to left is "multiplied by 2", so 10 shifts are 2^10 = 1024, which is the "byte to kilobyte" formula... no clue if that's understandable now xD
    timescale 0.01

  4. #4
    ... connecting woodchop146's Avatar
    Join Date
    Aug 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just gonna clear up Kung's failure:
    1 << 1 returns 2
    1 << 2 returns 4
    1 << 3 returns 8

    As you can see the number you set after the << is relative to how far into a binary sequence you are.
    0:1
    1:2
    2:4
    3:8
    4:16
    5:32
    6:64

    If you can't find the pattern then you have so very much to learn.

  5. #5
    ... connecting woodchop146's Avatar
    Join Date
    Aug 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In addition:
    Click image for larger version. 

Name:	Cpp cheat sheet.jpg 
Views:	42 
Size:	1.74 MB 
ID:	400
    Rather basic but you can google for other pages, pretty much teaches you all of basic C++(syntax and keywords).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •