Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-14-2010, 10:44 AM   #1
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.

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

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?

Old 12-15-2010, 09:53 AM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.


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 06:49 AM
unsigned long int uint32_t to unsigned char and back MicahCarrick Programming 2 08-02-2009 01:39 AM
printf unsigned long long int? blackzone Programming 9 03-04-2008 12:41 PM
conversion specifier for unsigned long in C ashlesha Programming 2 11-20-2006 01:20 PM
invalid conversion from 'long unsigned int*' to 'uint32*' quarry_06 Programming 8 12-23-2005 11:00 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:45 PM.

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