科学计数法(带负数) F_E(number, decimal = 2, yi = 'E')

// 科学计数法(带负数)    v2
function F_E(number, decimal = 2, yi = 'E') {
  var num = "";
  var minus = "";
  if (number < 0) minus = "-";
  number = Math.abs(number);
  if (number < 1000) {
      num = number;
  } else if (number >= 1000 && number < 1000000) {
      num = cutZero(formatDecimal(number / 1000, decimal)) + "K";
  } else if (number >= 1000000 && number < 100000000) {
      num = cutZero(formatDecimal(number / 1000000, decimal)) + "M";
  } else if (number >= 100000000) {
      if (yi && yi == 'E') {
          num = cutZero(formatDecimal(number / 100000000, decimal)) + "E";
      } else {
          num = cutZero(formatDecimal(number / 1000000, decimal)) + "M";
      }
  }
  return `${minus}${num}`;
}

posted @ 2024-07-05 15:03  半遮  阅读(12)  评论(0编辑  收藏  举报