Description
infinite precision(무한 정밀도) 에 대한 논의는 constant expression 챕터 리뷰과정에서 시작되었고, conversion 챕터 리뷰과정에서 implicit infinite precision 관련해서 추가 토의가 진행중입니다.
constant expression 챕터에서 infinite precision이 언급된 문장은 다음과 같습니다.
This rounding may cause a floating-point constant expression to be invalid in an integer context, even if it would be integral when calculated using infinite precision, and vice versa.
번역문: 무한 정밀도(infinite precision)로 계산해서 정수가 나오는 경우에도 이런 현상이 발생할 수 있으며, 그 반대의 경우도 마찬가지다.
아래는 constant expression 챕터 리뷰 과정에서 나온 infinite precision 관련 토의내용입니다.
- math/big 패키지를 이용한 의미로 해석할 수도 있다는 의견도 있었고,
- 정밀도를 사람이 하는 수준으로 높여서 계산을 하면 정상적으로 정수가 되는 계산이지만, 부동소수점으로 계산하면 값이 달라지는 상황을 의미한다는 의견도 있었습니다.
conversion 챕터에서 infinite precision이 언급된 문장은 다음과 같습니다.
When converting between integer types, if the value is a signed integer, it is sign extended to implicit infinite precision; otherwise it is zero extended.
참고 문서
infinite precision는 arbitary precision이라고도 불립니다. infinite precision 에 대한 wikipedia 정의는 다음과 같습니다.
In computer science, arbitrary-precision arithmetic, also called bignum arithmetic, multiple-precision arithmetic, or sometimes infinite-precision arithmetic, indicates that calculations are performed on numbers whose digits of precision are limited only by the available memory of the host system.
주로 매우 큰 수(big number)를 다뤄야 할 때 자주 언급되는 개념이지만, 꼭 큰 수에만 국한된 문제는 아닙니다.
Go 2 proposal 에서 overhead 를 피하기 위한 방법으로 change int to be arbitrary precision 이 제안되었습니다. 관련 이슈는 golang/go#19623 에서 확인할 수 있습니다.
아래는 infinite precision 및 conversion과 관련해서 추가로 참고할 만한 글들입니다.
-Go lang FAQ, Why does Go not provide implicit numeric conversions?
-Go blog, constants
부연 설명
추가적인 의견과 설명은 코멘트에 남겨주시길 바랍니다.