Project

General

Profile

1
export interface NumberSize {
2
  number: number;
3
  size: "M" | "K" | "";
4
  count: number;
5
}
6

    
7
export class NumberUtils{
8
  
9
  public static roundNumber(num: number):any {
10
      //console.log("Trying to round number: "+ num);
11
      var roundNum: NumberSize = null;
12
      var initialNum = num;
13
      if(num >= 1000000){
14
        num=num/1000000;
15
        num= Math.round(num);
16
        roundNum =  { number: num, size: "M", count: initialNum};
17
      }else if( num >= 1000){
18
        num=num/1000;
19
        num= Math.round(num);
20
        roundNum =  { number: num, size: "K", count: initialNum};
21
      }else if (num >= 100) {
22
        num=num/100;
23
        num= Math.round(num);
24
        num=num*100;
25
        roundNum =  { number: num, size: "" , count: initialNum};
26
      }else{
27
        roundNum =  { number: num, size: "" , count: initialNum};
28
      }
29
      return roundNum;
30
  }
31

    
32

    
33

    
34
}
(14-14/22)