Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bit Fields
#1
Code:
Unused_1 = 1
  Unused_2 = 2
  Unused_4 = 4
  Unused_8 = 8
  Unused_16 = 16
  Unused_32 = 32
  Unused_64 = 64
  Unused_128 = 128
Isnt that the fibbinaschi code (from 'the davinci code') or however you spell it?
Reply
#2
no way william
those are mostly powers of 2...
http://en.wikipedia.org/wiki/Fibonacci_number
Reply
#3
Ohh yeah, now I remember Tongue
Reply
#4
Wow, you've managed to complicate simple bitwise operators. :wink: :lol:
Reply
#5
Fibonati is like this:
Code:
F(0)=0
F(1)=1
F(N)=F(N-1)+F(N-2)
That's all you need, so, for ex Fibonati(6):
Fibonati(6)=Fibonati(5)+Fibonati(4)
Fibonati(5)=Fibonati(4)+Fibonati(3) Fibonati(4)=Fibonati(3)+Fibonati(2)
Fibonati(4)=Fibonati(3)+Fibonati(2) Fibonati(3)=Fibonati(2)+Fibonati(1)
Fibonati(3)=Fibonati(2)+Fibonati(1) Fibonati(2)=Fibonati(1)+Fibonati(0)
Replacing...
Fibonati(3)=Fibonati(2)+1 Fibonati(2)=1+0=1
Fibonati(3)=1+1=2
Fibonati(4)=2+1=3 Fibonati(3)=2
Fibonati(5)=3+2=5 Fibonati(4)=3
Fibonati(6)=5+3=8
So Fibonati(6)=8
Pretty good example of a recursive algorithm.
Reply
#6
Sorry for being noob but...

Whats enum? and where do you put it?

Also i dont fully understand why the bitfields double each time and why the bitfield has to = 1 byte (can it be less? so i have 1bit in the bitfield?)
Reply
#7
Enums are kind of like fancy constants. You should probably put it in either modtypes or modconstants, though really you could put it almost anywhere.
Reply
#8
Just for the record, since Ints and Longs are signed, you have to get the last bit by:

Int: -(((2 ^ 16) / 2) - 1)
Long: -(((2 ^ 32) / 2) - 1)

I believe that is correct, anyways. :wink:
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)