diff git a/functions.py b/functions.py
index ddc1088..c777af3 100644
a

b

def _d(val): 
86  86  else: 
87  87  return None 
88  88  
89   _angle_scaling = 1 
 89  class ClassValue(): 
 90  """ 
 91  Class to share a value with the outside world. 
 92  This is required because plain floats / integers are not asigned by 
 93  reference, and can therefore not easily be changed in a different place. 
 94  """ 
 95  def __init__(self, val): 
 96  self.value = val 
 97  
 98  angle_scaling = ClassValue(1.0) 
 99  
90  100  def _scale_angle(x): 
91   return x * _angle_scaling 
 101  return x * angle_scaling.value 
92  102  
93  103  def _inv_scale_angle(x): 
94   return x / _angle_scaling 
 104  return x / angle_scaling.value 
95  105  
96  106  def abs(x): 
97  107  return math.fabs(x) 
… 
… 
def mod(x, y): 
289  299  return x % y 
290  300  else: 
291  301  raise ValueError(_('Can only calculate x modulo <integer>')) 
 302  mod.__doc__ = _( 
 303  'mod(x, y), return the modulus of x with respect to y. This is the remainder \ 
 304  after dividing x by y.') 
292  305  
293  306  def mul(x, y): 
294  307  if isinstance(x, _Decimal) or isinstance(y, _Decimal): 
diff git a/mathlib.py b/mathlib.py
index 610bb07..c1ae273 100644
a

b

class MathLib: 
40  40  FORMAT_SCIENTIFIC = 2 
41  41  
42  42  def __init__(self): 
43   self.set_angle_type(self.ANGLE_DEG) 
44  43  self.set_format_type(self.FORMAT_SCIENTIFIC) 
45  44  self.set_digit_limit(9) 
46  45  
… 
… 
class MathLib: 
69  68  if len(self.div_sym) == 0 or len(self.div_sym) > 3: 
70  69  self.div_sym = '/' 
71  70  
72   def set_angle_type(self, type): 
73   self.angle_scaling = self.d(type) 
74   _logger.debug('Angle type set to %s', self.angle_scaling) 
75   
76  71  def set_format_type(self, fmt, digit_limit=9): 
77  72  self.format_type = fmt 
78  73  _logger.debug('Format type set to %s', fmt) 
diff git a/toolbars.py b/toolbars.py
index 69cc940..221dbd7 100644
a

b

class MiscToolbar(gtk.Toolbar): 
290  290  target_toolbar.insert(IconToggleToolButton(el, 
291  291  lambda x: self.update_angle_type(x, calc), 
292  292  _('Degrees / radians')), 1) 
 293  self.update_angle_type('deg', calc) 
293  294  
294  295  el = [ 
295  296  {'icon': 'formatsci', 'html': 'sci'}, 
… 
… 
class MiscToolbar(gtk.Toolbar): 
312  313  self.show_all() 
313  314  
314  315  def update_angle_type(self, text, calc): 
 316  var = calc.parser.get_var('angle_scaling') 
 317  if var is None: 
 318  _logger.warning('Variable angle_scaling not defined.') 
 319  return 
 320  
315  321  if text == 'deg': 
316   calc.ml.set_angle_type(MathLib.ANGLE_DEG) 
 322  var.value = MathLib.ANGLE_DEG 
317  323  elif text == 'rad': 
318   calc.ml.set_angle_type(MathLib.ANGLE_RAD) 
319   _logger.debug('Angle type: %s', calc.ml.angle_scaling) 
 324  var.value = MathLib.ANGLE_RAD 
 325  _logger.debug('Angle scaling: %s', var.value) 
320  326  
321  327  def update_format_type(self, text, calc): 
322  328  if text == 'exp': 
323  329  calc.ml.set_format_type(MathLib.FORMAT_EXPONENT) 
324  330  elif text == 'sci': 
325   calc.ml.set_angle_type(MathLib.FORMAT_SCIENTIFIC) 
 331  calc.ml.set_format_type(MathLib.FORMAT_SCIENTIFIC) 
326  332  _logger.debug('Format type: %s', calc.ml.format_type) 
327  333  
328  334  def update_digits(self, text, calc): 