in reply to Re: Re: What is the perl equivelant to a 'Set' column type in mysql?
in thread What is the perl equivelant to a 'Set' column type in mysql?

Small logic nit. The set bits are 0 1 2 4 8.... In your example a jazzy pop band would be a metal entity as well as a last....It is also worth noting that you can only rely on 31-32 (sign bit) genres unless you can guarantee long 64 bit ints.

cheers

tachyon

  • Comment on Re: Re: Re: What is the perl equivelant to a 'Set' column type in mysql?

Replies are listed 'Best First'.
Re: Re: Re: Re: What is the perl equivelant to a 'Set' column type in mysql?
by sgifford (Prior) on May 01, 2004 at 20:25 UTC
    I think you missed the part where I used the sequential numbers as a count for which bits to set or check; if not please elaborate, as I don't see the bug. In fact, the example I gave is a jazzy pop singer, and it works properly.

    Using powers of 2 for the constants is a good idea, though; I just thought it would be easier to explain this way.

      My mistake, I did not read the code carefully and ignored the bitshift logic ;-). I use OR logic for my masks

      my %genres = ( ROCK => 0, POP => 1, JAZZ => 2, } my $bits = 0; $bits |= $genres{$_} for @spec;

      cheers

      tachyon