Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: bbj17 at gmx.de <bbj17@gmx.de>
To: buildroot@busybox.net
Subject: [Buildroot] float, va_arg, printf on x86_64
Date: Mon, 03 Aug 2009 17:17:49 +0200	[thread overview]
Message-ID: <20090803151749.224000@gmx.net> (raw)

Hi,

I use buildroot-2009.08-rc1 and want to build a small system for a 64-Bit system.
I build my version with the following settings: 
Target architecture = x86_64
kernel type = advanced
kernel version = 2.6.30.2

The target image boots fine and everything is working, except the output of float values:

(printf - busyboy) => printf %f 7 => 0.000000
(printf - ash) => printf %f 7 => -2681561585988519419770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

(tcl format) => format %f 7 => 0.000000

Only perl-printf works right.
Can anyone explain this behaviour?

PS: same with buildroot-2009.05

c-code example:

#include <fcntl.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <stdarg.h>


void my(int param1, ...) {
     double f;
     va_list argptr;

    va_start( argptr, param1 );
      f = va_arg( argptr, double );
      va_end( argptr );

      if (f==4.2) {
      printf("YES #2\n");
    }

    printf("my -> %.2f \n", f);

}

int main(int argc, char *argv[]) {

  float f3;
  f3 = 4.2f;

  printf("%d\n", (int)f3);
  if (f3==4.2f) {
        printf("YES %2.2f\n",f3);
  }

  my(3,f3);
  return 0;

}


correct output (opensuse 10.2):
./a.out
4
YES 4.20
my -> 4.20

incorrect output (BR-2009.08-rc1):
./testprintf
4
YES 0.00
my -> 0.00

If the target architecture is 32-Bit everything is OK!

Regards BC

-- 
GRATIS f?r alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

             reply	other threads:[~2009-08-03 15:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-03 15:17 bbj17 at gmx.de [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-08-04  9:30 [Buildroot] float, va_arg, printf on x86_64 bbj17 at gmx.de
2009-08-04  9:37 ` Peter Korsgaard

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=20090803151749.224000@gmx.net \
    --to=bbj17@gmx.de \
    --cc=buildroot@busybox.net \
    /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