naah, thanks, that's ok.
As soon as I can acquire my own turing machine, I'll insist on 1 number type.
Until then I can live with different number types and some rules for
my finite machines.
On 5/21/19, Michael Jones <
michae...@gmail.com> wrote:
> Oh, Sorry. Have been away from email today. (Focused 100% in VS-code on a
> cool feature for Go)
>
> My statement was meant to convey an insight into a subtle aspect of Go's
> constants and high-precision expression evaluation--that the "type" of
> untyped constants/values, in the conversion rules sense, is derived in the
> instant of the conversion and is not an inherent trait of the value as is
> quite generally the case in other languages and situations. Also I think,
> the spec document is a little deceptive here, or at least, it needs to be
> read creatively to understand what all the possibilities are.
>
> In this case, the original question by Djadala was about a const "6.6" not
> being able to be coerced to integer form in either of two ways of
> trying ("x = int(y)" and "x int = y"). Both you and Jan explained why this
> is so and where/how it is defined in the specification. That was
> authoritative.
>
> However, the original question was worded in such a way that I could not
> discern if he was asking "please share the official reason why this seems
> impossible" or if instead he/she meant, "can I do this? I've tried two
> ways, and it seems impossible." I'm very supportive of the "how can I make
> it work?" sentiment and I doubted that the OP would figure it out since the
> two responses seemed so absolute, so I weighed in.
>
> Here's the subtle point. *That 6.6 constant "y" is NOT a floating-point
> value.* it's value just happens to "be as if floating" at the moment.
> However, "y*10" evaluates to 66, and that is a "just plain 66" not "10
> times the floating point 6.6, therefore an inherent floating point value of
> 66.0" The upshot is that Djadala cannot get "y" into an int, but can easily
> get "10*y" into one, and having done so, can make that integer 66 into the
> integer 6 via truncating integer division as I showed in the linked Go
> Playground example:
https://play.golang.org/p/7gcb9Yv7c9e
>
> Since the "6.6" has one decimal place making y *be as if floating point,*
> multiplication by an integer multiple of 10 is enough to clear the decimals
> and let it *be as if integer* in arbitrary expressions. If it was "6.67" (2
> places) or "6.678" (three places), then the least power of ten to clear the
> "as if floating" problem Djadala faced would be "10**k, k >= number of
> decimals" as was indicated in my comment in the linked Playground example.
>
> Sadly, this is not a general-purpose, remedy because the magic expression
> evaluation logic insists that values fit into the target size; were it not
> this way, we might imagine multiplying by 10**k, k>=19, capturing the
> integerness of the expression in that instant, and then dividing by the
> same factor. Alas, we'll be stopped right there because the expression,
> while *as if an integer,* is simultaneously, *as if too big to fit into
> one. *Since 64-bit ints are big and the OP was wrestling with only one