public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Amit Hiremath <amit.hmath@googlemail.com>
To: henri.cloetens@blueice.be
Cc: gcc-help@gcc.gnu.org
Subject: Re: Decimal to floating point and floating point to decimal conversion
Date: Wed, 12 Jul 2023 14:46:15 +0530	[thread overview]
Message-ID: <CANGfS-PZsQnY7cKSTjyokohiWYo=a=0kR7v+KP=RFoN9NACoWA@mail.gmail.com> (raw)
In-Reply-To: <26aac916830bb9a2518fef98e0ef3e67@blueice.be>

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

OK thanks Henri.

On Mon, Jul 10, 2023 at 11:52 PM <henri.cloetens@blueice.be> wrote:

> Hello Amit,
>
> If you want to do this conversion in C, proceed as follows :
>
> #include "stdio.h"
> #include "stdlib.h"
>
> int main()
> {
> float a = 3.2444422 ;
> int *p = (int *)(&a) ;
> fprintf(stderr,"%08x\n",*p) ;
> }
>
> It will print the hex value, which happens to be the same as yours on my
> machine.
> To convert opposite way, you need to do the opposite pointer
> manipulation.
>
> Best Regards,
>
> Henri.
> ~
>
>
> On 2023-07-10 12:27, Amit Hiremath via Gcc-help wrote:
> > Hi,
> >
> > Can you please point me to codes in GCC where numbers in human readable
> > format to floating point and floating point to human readable format
> > conversion are taking place? For example: 3.2444422
> > -->404FA4F1-->3.2444422
> >
> > int main ()
> > {
> > float a;
> >
> > a= 3.2444422;
> >
> > return 0;
> >
> > }
> > when you generate asm code, the assembler code is converted to
> > 404FA4F1. So
> > I am looking for a code in the gcc compiler.
> >
> > Thanks,
> > -Amit
>

      parent reply	other threads:[~2023-07-12  9:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10 10:27 Amit Hiremath
2023-07-10 11:42 ` Jonathan Wakely
2023-07-10 11:45   ` Jonathan Wakely
2023-07-10 12:59   ` Amit Hiremath
2023-07-10 13:13     ` Matthias Pfaller
2023-07-10 17:12       ` Richard Earnshaw
2023-07-10 18:22 ` henri.cloetens
2023-07-11  9:44   ` Jonathan Wakely
2023-07-11 12:33     ` henri.cloetens
2023-07-11 12:45       ` Jonathan Wakely
2023-07-11 12:47       ` Xi Ruoyao
2023-07-11 12:47       ` Andrew Haley
2023-07-12  9:16   ` Amit Hiremath [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANGfS-PZsQnY7cKSTjyokohiWYo=a=0kR7v+KP=RFoN9NACoWA@mail.gmail.com' \
    --to=amit.hmath@googlemail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=henri.cloetens@blueice.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).