subroutine toggle_degrees_mode(new_mode)
logical, intent(in) :: new_mode
integer :: i
type(rpn_t) :: rz
! Only do something if the modes are different
if (new_mode .eqv. degrees_mode) return
degrees_mode = .not. degrees_mode
! Convert all polar complex numbers
! 1) In the stack
do i=1,stack%ssize
rz = stack%peek(i)
call update_angle_unit(rz)
call stack%set(rz,i)
end do
! 2) in memory
do i=lbound(mem,1),ubound(mem,1)
call update_angle_unit(mem(i))
end do
! 3) in multiple roots
do i=1,nroots
call update_angle_unit(roots(i))
end do
end subroutine toggle_degrees_mode