| 1544 | */ |
| 1545 | template<class ValueType> |
| 1546 | ValueType DegToRad(const ValueType & x, ErrorCode * err = 0) |
| 1547 | { |
| 1548 | ValueType result, temp; |
| 1549 | uint c = 0; |
| 1550 | |
| 1551 | if( x.IsNan() ) |
| 1552 | { |
| 1553 | if( err ) |
| 1554 | *err = err_improper_argument; |
| 1555 | |
| 1556 | return x; |
| 1557 | } |
| 1558 | |
| 1559 | result = x; |
| 1560 | |
| 1561 | // it is better to make division first and then multiplication |
| 1562 | // the result is more accurate especially when x is: 90,180,270 or 360 |
| 1563 | temp = 180; |
| 1564 | c += result.Div(temp); |
| 1565 | |
| 1566 | temp.SetPi(); |
| 1567 | c += result.Mul(temp); |
| 1568 | |
| 1569 | if( err ) |
| 1570 | *err = c ? err_overflow : err_ok; |
| 1571 | |
| 1572 | return result; |
| 1573 | } |
| 1574 | |
| 1575 | |
| 1576 | /*! |