LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 02-08-2005, 04:51 AM   #1
dand
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, 07:54 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,114

Rep: Reputation: 312Reputation: 312Reputation: 312Reputation: 312
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, 03:34 AM   #3
dand
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, 03:39 AM   #4
dand
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.
 
  


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


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


All times are GMT -5. The time now is 05:27 PM.

Main Menu
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