Skip to content

Commit

Permalink
use Math.trunc
Browse files Browse the repository at this point in the history
  • Loading branch information
kewde committed Nov 5, 2017
1 parent 5ef8784 commit 2490b16
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/app/shared/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ export class Amount {
* 25.9 -> '25'
*/
public getIntegerPart(): number {
/* Math floor is crazy.
* Math.floor(-0.2) -> -1.2, so fix it by adding 1 if negative &
* Math.floor(-9) -> -9, so only add 1 if no dot exists.
*/
return Math.floor(this.amount) + Number(this.amount < 0 && this.ifDotExist());
return Math.trunc(this.amount);
}

/**
Expand Down

0 comments on commit 2490b16

Please sign in to comment.