Mirage Source
Bit Fields - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: Bit Fields (/showthread.php?tid=557)



- William - 30-12-2006

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?


- Misunderstood - 30-12-2006

no way william
those are mostly powers of 2...
http://en.wikipedia.org/wiki/Fibonacci_number


- William - 30-12-2006

Ohh yeah, now I remember Tongue


- Spodi - 30-12-2006

Wow, you've managed to complicate simple bitwise operators. :wink: :lol:


- Dragoons Master - 02-01-2007

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.


- Bakekitsune - 11-02-2007

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?)


- Misunderstood - 11-02-2007

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.


- Spodi - 11-02-2007

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: