Skip to main content
bug fix
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
SetAttributes[num, NHoldAll] 

num /: num[x_] * (num[y_] | y_.) := num[x * y]
num /: num[x_] + (num[y_] | y_.) := num[x + y] 

Format[num[x_]] := N[x]

g[num[x_] | x_, n_] := num @ Round[x, 10^(1 - n + ⌊Log10@Abs@x⌋)]
SetAttributes[num, NHoldAll]
num /: num[x_] * y_. := num[x * y]
num /: num[x_] + y_. := num[x + y]
Format[num[x_]] := N[x]

g[num[x_] | x_, n_] := num @ Round[x, 10^(1 - n + ⌊Log10@Abs@x⌋)]
SetAttributes[num, NHoldAll] 

num /: num[x_] * (num[y_] | y_.) := num[x * y]
num /: num[x_] + (num[y_] | y_.) := num[x + y] 

Format[num[x_]] := N[x]

g[num[x_] | x_, n_] := num @ Round[x, 10^(1 - n + ⌊Log10@Abs@x⌋)]
added 2271 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
Loading
added 242 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
Loading
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
Loading