| 1681 | */ |
| 1682 | template<class ValueType> |
| 1683 | ValueType GradToRad(const ValueType & x, ErrorCode * err = 0) |
| 1684 | { |
| 1685 | ValueType result, temp; |
| 1686 | uint c = 0; |
| 1687 | |
| 1688 | if( x.IsNan() ) |
| 1689 | { |
| 1690 | if( err ) |
| 1691 | *err = err_improper_argument; |
| 1692 | |
| 1693 | return x; |
| 1694 | } |
| 1695 | |
| 1696 | result = x; |
| 1697 | |
| 1698 | // it is better to make division first and then multiplication |
| 1699 | // the result is more accurate especially when x is: 100,200,300 or 400 |
| 1700 | temp = 200; |
| 1701 | c += result.Div(temp); |
| 1702 | |
| 1703 | temp.SetPi(); |
| 1704 | c += result.Mul(temp); |
| 1705 | |
| 1706 | if( err ) |
| 1707 | *err = c ? err_overflow : err_ok; |
| 1708 | |
| 1709 | return result; |
| 1710 | } |
| 1711 | |
| 1712 | |
| 1713 | /*! |