Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 02-08-2005, 05:51 AM   #1
LQ Newbie
Registered: Dec 2004
Posts: 18

Rep: Reputation: 0
difference between int64_t on unix and linux

I have found a bug in our code.

The line is:

int64_t iBase = (int64_t) (d1 / d2);

where d1 and d2 are doubles.

if d1 = 3000 and d2 = 0.01,

for Unix, iBase is calculated as 299999

but for Linux, iBase is calculated as 300000 (which is correct!)

Does anyone know why this is happening or where I can find the definition for int64_t on Linux?

Cheers, Dan.
Old 02-08-2005, 08:54 PM   #2
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
int64_t is guaranteed to be a 64 bit signed integer if you compiler follows the C99 standard. The exact mechanics of floating point rounding are probably more dependant on your hardware than on your OS. Can you post some more detail about the Unix platform this was running on (there hasn't been one single Unix since about the mid '70s), in particular the hardware.

Also, this may be better off in the programming forum (ask a mod to move it).
Old 02-09-2005, 04:34 AM   #3
LQ Newbie
Registered: Dec 2004
Posts: 18

Original Poster
Rep: Reputation: 0
Solaris 5.8

arch = sun4
uname = SunOS

Is that enough?

Cheers, Dan.
Old 02-09-2005, 04:39 AM   #4
LQ Newbie
Registered: Dec 2004
Posts: 18

Original Poster
Rep: Reputation: 0
btmiller, I'm afraid I put that the wrong way around!

It calculates it as 300000 on Unix which is correct and 299999 on Linux which is incorrect. It is a problem with Linux (RHAS3)

Sorry, Dan.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
difference between Linux/Unix gfrair Linux - Newbie 16 08-18-2017 10:29 AM
difference between int64_t on unix and linux dand Programming 4 02-09-2005 01:18 PM
what is the difference between unix and linux terry.trent Linux - General 5 01-12-2004 07:09 PM
Difference between UNIX and LINUX cirkut5732 Slackware 4 07-09-2003 03:00 PM
Difference between Linux and Unix plisken Linux - General 5 02-19-2003 10:29 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:36 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
Open Source Consulting | Domain Registration