export const setComma = (value) => {
  if (value == null) return "0";

  const num = typeof value === "string" ? parseFloat(value) : value;

  if (isNaN(num)) return value;

  return num.toLocaleString("en-US", {
    minimumFractionDigits: 0,
    maximumFractionDigits: 2
  });
};

export const setCommaRegex = (value) => {
  if (value == null) return "0";

  const str = String(value);
  const parts = str.split(".");

  // 정수 부분에 콤마 추가
  parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");

  return parts.join(".");
};