Does the alarm work when my phone is turned off? Will the alarm still go off if I turn off the phone before?

Example: when I have low battery, I have to go to sleep and wake up at X o'clock, and there is no charger around. Should I turn off the phone? 

Note: If it makes any difference my phone is Galaxy S running froyo
No, if the phone is off, it can't do anything.  If it's in sleep mode where the screen is off and it's not in use then the alarm will still function as will other types of notifications.  I have never tried this specifically on a Galaxy S but I am fairly confident this is a universal rule.