LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 12-14-2010, 11:44 AM   #1
random0
LQ Newbie
 
Registered: Jun 2006
Location: Gainesville, Fl, USA
Distribution: Debian GNU/Linux
Posts: 18

Rep: Reputation: 0
C double to unsigned long long Conversion with mingw32


The following line is not working for me under mingw32.

Code:
printf("%.0f == %llu\n", 45252301458.0, (unsigned long long)(45252301458.0));
The output is:

Quote:
45252301458 == 2302628498
This is clearly incorrect. 64 bits is more than enough to represent such an integer, so why is it failing? Can I work around this?

Thanks.
 
Old 12-15-2010, 10:53 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Are you sure that your compiler treats 'unsigned long long' as a 64 bit integer? Does printf() support 'long long'? Try splitting the 64-bit integer into two 32-bit integers, and try printf()ing those independently.

--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] About the 'unsigned long long' type lesca Programming 4 10-24-2010 07:49 AM
unsigned long int uint32_t to unsigned char and back MicahCarrick Programming 2 08-02-2009 02:39 AM
printf unsigned long long int? blackzone Programming 9 03-04-2008 01:41 PM
conversion specifier for unsigned long in C ashlesha Programming 2 11-20-2006 02:20 PM
invalid conversion from 'long unsigned int*' to 'uint32*' quarry_06 Programming 8 12-23-2005 12:00 PM


All times are GMT -5. The time now is 04:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration