| Deutsch English Français Italiano |
|
<v929ah$3u7l7$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!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: Thu, 8 Aug 2024 08:14:25 -0300 Organization: A noiseless patient Spider Lines: 55 Message-ID: <v929ah$3u7l7$1@dont-email.me> References: <v8vlo9$2oc1v$1@dont-email.me> <slrnvb7kis.28a.dan@djph.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 08 Aug 2024 13:14:26 +0200 (CEST) Injection-Info: dont-email.me; posting-host="c24a25e0e0574963f5160c2b1c68553a"; logging-data="4136615"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18r8Z9TBnRz2P8vNA7zx13XP7ACp55m2gk=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:G780AdLArSvDCy3m5MjXKM2agp4= In-Reply-To: <slrnvb7kis.28a.dan@djph.net> Content-Language: en-US Bytes: 2600 On 07/08/2024 17:00, Dan Purgert wrote: > On 2024-08-07, Thiago Adams wrote: >> How cast works? >> Does it changes the memory? >> For instance, from "unsigned int" to "signed char". >> Is it just like discarding bytes or something else? >> [...] > > I don't know what happens when you're changing datatype lengths, but if > they're the same length, it's just telling the compiler what the > variable should be treated as (e.g. [8-bit] int to char) > >> >> I also would like to understand better signed and unsigned. >> There is no such think as "signed" or "unsigned" register, right? > > "Signed" just means the first bit indicates negative. > > So an "unsigned" 8 bit integer will have the 256 values ranging from > > 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 = 0 > (0b00000000) > > TO > > 128 + 64 + 32 + 16 + 8 +4 + 2 + 1 = 255 > (0b11111111) > > > Whereas a "signed" 8 bit integer will have the 256 values ranging from > > (-128) + 0 + 0 + 0 + 0 + 0 + 0 + 0 = -128 > (0b10000000) > > TO > > 0 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 127 > (0b01111111) > > At least in two's compliment (but that's the way it's done in C) > > >> How about floating point? > > Floating point is a huge mess, and has a few variations for encoding; > though I think most C implementations use the one from the IEEE on 1985 > (uh, IEEE754, I think?) > I didn't specify properly , but my question was more about floating point registers. I think in this case they have specialized registers.