github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/dashboard/frontend/src/utils/format.ts (about)

     1  export const formatFloat = (num: number | undefined): number => {
     2    if (num === undefined) {
     3      return 0
     4    }
     5    return Math.round(num * 100) / 100
     6  }
     7  
     8  export const subtractFloat = (a: number | undefined, b: number | undefined): number => {
     9    const useA = a || 0
    10    const useB = b || 0
    11    return formatFloat(useA - useB)
    12  }