It would be very useful to document the type of the input variable 'a'. Even thought this code is only internal, it is difficult to read because it is quite dependence on the type of a.