Question: I have weird decimal calculation that really surprise me, I have two big decimal number, one is a normal proce and the other one is an offer price. Then I want to calculate discount percentage and ceil it to the nearest integer. 

Here are the code:

```
BigDecimal listPrice = new BigDecimal(510000);
BigDecimal offerPrice = new BigDecimal(433500);
int itemDiscount = (int)Math.ceil(((listPrice.longValue() - offerPrice.longValue()) / (float) listPrice.longValue()) * 100);

```

I expect it would set 15 as value of itemDiscount, but surprisingly it has 16, wow. Then i print each calculation to show in which statement is the problem, so i put System.out.println for each statement as below :

```
System.out.println(listPrice.longValue() - offerPrice.longValue()); //==> show 76500
System.out.println((listPrice.longValue() - offerPrice.longValue()) / (float) listPrice.longValue()); // ==> 0.15
System.out.println((listPrice.longValue() - offerPrice.longValue()) * 100 / (float) listPrice.longValue()); // ==> 15.000001

```

the problem is in above statement, istead of returning 15.0, it return 15.000001. And when i ceil it, it will of course return 16 instead of 15. 

What is the explanation if this case? is this the way it is or it is a bug?

Answer: 
One possible solution is to use a custom event `showalert` after the alert is shown and in the event handler remove the alert

```
$(document).on('showalert', '.alert', function(){
    window.setTimeout($.proxy(function() {
        $(this).fadeTo(500, 0).slideUp(500, function(){
            $(this).remove(); 
        });
    }, this), 5000);
})  

```

and

```
$('<div class="alert alert-error">' + 'some message' + '</div>').appendTo('#result').trigger('showalert');

```

Demo: [Fiddle](http://jsfiddle.net/arunpjohny/UZUb4/)
I think it is because `$(this).remove();` removes the alert from the DOM. You can actually just modify the content without regenerating the alert every time after the AJAX call.