Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
YardKGnome
Jan 18, 2003
Grimey Drawer

Femtosecond posted:

I have a bit of code that I'm working on, and it has a use of '&' that I've never seen before.


I've seen rand() % 3 used a million times before, but never the &. It's still giving me random numbers but it seems like it's doing something a bit different. What does this do?

3 is 0011 in binary. & is the bit-wise and operator. Basically, its giving you a random number between 0 and 3 (inclusive). It is equivalent to "% 4"

Adbot
ADBOT LOVES YOU

YardKGnome
Jan 18, 2003
Grimey Drawer

very posted:

That seems like a bad idea. Somebody is going to want to add another case, change the 3 to a 4, and now you have a bug.

Yup. Seems like a pretty bad idea in general.

YardKGnome
Jan 18, 2003
Grimey Drawer

Hughmoris posted:

I'm trying to create a budget and expense tracker in google spreadsheet and I'm having a bit of trouble writing a function.


I want to write a function that will run through column D, and if it finds a Food transaction, add the appropriate amount to a running total in cell E2. The same goes for Gas and Misc. I tried searching their help topics but I can't figure it out. Thanks for the help.

Try
code:
=SUMIF(D6:D,E1,B6:B)
That is a sum of the values in row B (after B6) if the values in row D (after D6) match the value of the cell E1 (Food).

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply