let rec normalize v =
let n = 2. ** float_of_int (value_macro_to_int Faust_Bits_int) in
match v with
|N i ->
if i > value_macro_to_int Faust_Max_int then
return_N (i - int_of_float (n *. floor (((float_of_int i) +. n/.2.)/.n)))
else if i < value_macro_to_int Faust_Min_int then
return_N (i + int_of_float (n *. floor ((n/.2. -. (float_of_int i) -. 1.)/.n)))
else return_N i
|R f ->
if f > float_of_int (value_macro_to_int Faust_Max_int) then
return_R (f -. (n *. floor ((f +. n/.2.)/.n)))
else if f < float_of_int (value_macro_to_int Faust_Min_int) then
return_R (f +. (n *. floor ((n/.2. -. f -. 1.)/.n)))
else return_R f
|Vec (size, vec) -> make_vector size (fun i -> normalize (vec i))
|Zero -> Zero
|W -> W