If you are developing software during your boss his/her time, the rights belong to the company, it's THAT simple.. You even have to be cautious if you are a software developer at work and create other software at home, make sure you have an arrangement in your contract about that, because if you don't and you have a very nasty boss, he can claim right to your software you build at home (because you certainly would have thought about it at work, and sometimes even used algorithmes/structures developed at work)..
So if you want to own the right to software developed at work, you'll have to specify that in your contract, but I can almost guarantee you that no boss will do that... And the same goes for software created for a client, make sure the contract specifies who the rights have..
You must be very naive if you think you can own rights to software/algorithmes created at work...