Deutsch   English   Français   Italiano  
<v95q9m$2oa92$3@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Thiago Adams <thiago.adams@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: how cast works?
Date: Fri, 9 Aug 2024 16:22:30 -0300
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <v95q9m$2oa92$3@dont-email.me>
References: <v8vlo9$2oc1v$1@dont-email.me> <slrnvb7kis.28a.dan@djph.net>
 <v929ah$3u7l7$1@dont-email.me> <87ttfu94yv.fsf@nosuchdomain.example.com>
 <v93a3t$6q7v$1@dont-email.me> <v93e2q$8put$1@dont-email.me>
 <v94smd$mgp8$1@dont-email.me> <8734nd8qn7.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 09 Aug 2024 21:22:31 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="358699822bb9c263f3cfeb8ab794a410";
	logging-data="2894114"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/tsjKNPQC1pYtCOOIJYyt02Nkj31WC76M="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:zAA7ZrUmO8nVe3S0F0cdy91IcaY=
In-Reply-To: <8734nd8qn7.fsf@nosuchdomain.example.com>
Content-Language: en-GB
Bytes: 3167

Em 8/9/2024 4:03 PM, Keith Thompson escreveu:
> Thiago Adams <thiago.adams@gmail.com> writes:
> [...]
>> This part was always clear to me:
>>
>> "They  are not performed 'in-place', any more than writing `a + 1`
>> changes the value of `a`."
>>
>> Lets take double to int.
>>
>> In this case the bits of double needs to be reinterpreted (copied to) int.
> 
> The word "reinterpreted" usually refers to taking a given representation
> (sequence of bits) and treating it as a value of a specified type
> *without changing the bits*.  (<OT>C++ even has "reintrepret_cast" as a
> keyword.</OT>)
> 
> Converting from int to double does not reinterpret the bits.  It creates
> a new value that is mathematically equal (or nearly so) to the operand
> value.
> 
>> So the answer "how it works" can be
>>
>> always/generally machine has a instruction to do this
>>
>> or.. this is defined by the IIE ... standard as ...
> 
> Do you mean the IEEE standard?  As always, the C standard defines the
> semantics of conversions.  For an implementation that claims to conform
> to IEEE floating-point standard (ISO/IEC 60559), the semantics are
> specified more precisely.
> 

Yes. maybe the conversion double to int for instance, is related with 
truncation, and this is specified on IEEE.
The inverse int to double is similar. For instance ULLONGMAX to double.

I guess all computers languages works in the same way today because also 
hardware works following the floating point standards.


--

We already have many topics in one...but I am adding one more. :D 
_Decimal32 , _Decimal64 etc..

C23 have these new types. I think it has to me emulated because it is 
not something implemented on hardware.

C started as being something more hardware related, but now we have 
complex types, bool, _Decimal.. I think all these types are "emulated".