What you are talking about happening is a very good case in point for having an Uninterrupted Power Supply (UPS) for your computer. We have had one since we moved over to NH (9+ years) and we lose power or have fluctuations on a regular basis.
The battery backup will allow your computer to run on a nice clean flow of electricity (ups's have a filtering system to get rid of unwanted interference) and in essence, you actually run on battery power all the time. The electronics inside a computer are "delicate" and using a battery backup will help protect those components.
I have my Computer, my monitor, and an older cordless phone plugged into the battery backup side. I have my printer plugged into the "surge protection side" along with my scanner power. The backup is then plugged into a surge protector which is plugged into the wall. (Don't plug a surge protector into the back up!!!!!). When (if) (often happens

) we lose power, the battery backup will allow you to shut down safely and properly if necessary, and in our case, we have a phone available to use without having to dig into the closet for that non-cordless phone we have for emergencies.
Most boxed stock at a retail store will have an informational grid on the box that will tell you for this type of computer (tower, for example) and a monitor (17 in, for example) that boxed stock will allow
up to xx number of minutes to safely shut down. Don't skimp on the backup. It's like protecting your assets with insurance. Decent backups would run from about $60 to $100. Well worth it!!!!