If you set your stop as a percentage of the initial purchase price you can estimate the commissions and then deduct these from the $100 in the calculations.
For example, say you use a stop loss of 10% and for simplicity lets say your purchase price is $10.
Purchase price = $10
Stop = 10% x $10 = $1
Initial Stop Price = $10 - $1 = $9
If we ignore the commission for now, the number of units to buy from your formula would simply be:
$100/$1 = 100 units (so using this as an estimate)
From buying 100 units @ $10 each the total purchase would be $1000.
Thus the commission on $1000 @ 0.25% would be $2.50. As we don't know at what price you will sell at (as we don't know if you will make a profit or a loss) so we can use the same amount for the sell commission. So our estimated total commission for the round trade (in and out) would be $5.
Now we can include this into your formula:
No. of Units = ($100-$5)/($10-$9) = $95/$1 = 95 units.
If your commission was a fixed dollar amount you could simply deduct them from the $100 risk amount as above.
Where it becomes a bit more difficult is where your commission is percentage based (as yours is) and the initial stop varies from trade to trade (that is, it is not a fixed percentage). In this case you would probably need to estimate what your commission will be on each and every trade depending where your stop is, and then deduct this from the $100 in the formula. You will again need to double the commission for the entry as your exit commission won't be known until you sell.
If you want to be extra conservative then you could see what commissions you are paying after a number of trades, and use the maximum commission charged as a guideline. Then deduct this from the $100 in your formula. However, this will mean that you are purchasing less each trade.
Or you could take the average total commission after a number of trades and revise this regularly if you don't want to be too conservative.