473,770 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Different code behaviour in Unix & Windows

Hi,

I am doing some mathematical analysis on large numbers in C. The same
code runs perfectly in Windows but produces unpredictable results in
Unix (like negative numbers or very very big numbers).

I am using 'long' data type which is sufficient to hold the largest
data in the program. I checked the 'sizeof(long)' in both the OS which
is same (=4).

I need to integrate this program with other modules and run from Unix.
So I can not continue to run it from Windows.

Please let me know if you have any clue on the possible problem.

Thanks,
Saumi

Apr 18 '06
41 2259
On Wed, 19 Apr 2006 19:43:50 GMT, Keith Thompson <ks***@mib.or g> wrote:
"Vladimir S. Oka" <no****@btopenw orld.com> writes:
Nick Keighley opined:
tech guru wrote:
If I compile like 'gcc3 -o objName sourceName.c', it complains about
round() & sqrt() even if math.h is included.

try linking with the math library (see the clc FAQ for more info)

gcc -lm etc.

Alos just how standard in round()? I'm pretty sure its not C89.
It's not in my C89 draft, but it is in N1124, so I suppose it's C99.


round() is standard in C99, but not in C90.

I think we recently had a thread here where someone's compiler (I
think it was gcc) recognized round(), possibly implementing it with
inline code, but the system's <math.h> header didn't declare it.


I remember one about pow() being replaced by GCC at compile time with
the result for some values. Perhaps this is the one you recall too?

The starting message was the one with:

From: Mark Healey <d...@spammer.d ie>
Subject: I can't seem to use pow()
Message-Id: <pa************ *************** *@spammer.die>
(The compiler, headers, and library are all part of the implementation
as far as the standard is concerned, but if they're provided by
different vendors or other entities they can be inconsistent.) Since
no declaration for round() was visible, the compiler had to assume
that it returns int. (And no, casting the result to double is *not* a
fix for the problem; it merely masks the error.)

I have no idea whether that's the problem here, but it's worth
investigating.


The point made above is also valid though :)

Apr 19 '06 #41
Giorgos Keramidas <ke******@ceid. upatras.gr> writes:
On Wed, 19 Apr 2006 19:43:50 GMT, Keith Thompson <ks***@mib.or g> wrote:
"Vladimir S. Oka" <no****@btopenw orld.com> writes:
Nick Keighley opined:
tech guru wrote:
> If I compile like 'gcc3 -o objName sourceName.c', it complains about
> round() & sqrt() even if math.h is included.

try linking with the math library (see the clc FAQ for more info)

gcc -lm etc.

Alos just how standard in round()? I'm pretty sure its not C89.

It's not in my C89 draft, but it is in N1124, so I suppose it's C99.


round() is standard in C99, but not in C90.

I think we recently had a thread here where someone's compiler (I
think it was gcc) recognized round(), possibly implementing it with
inline code, but the system's <math.h> header didn't declare it.


I remember one about pow() being replaced by GCC at compile time with
the result for some values. Perhaps this is the one you recall too?

The starting message was the one with:

From: Mark Healey <d...@spammer.d ie>
Subject: I can't seem to use pow()
Message-Id: <pa************ *************** *@spammer.die>


No, that wasn't it. The thread I'm thinking of had the subject
"undefined refrence to a function" (the typo should make it easy to
find in Google).

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 19 '06 #42

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3019
by: Peter Abel | last post by:
Hi all, I'm working under W2k with Python 2.2.2 (#37, Oct 14 2002, 17:02:34) on win32 I have a file *test_data.txt* with the following content: 0123456789 0123456789 abcdefghi ABCDEFGHIJKLMNOPQ
137
7182
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very pragmatic - 3) I usually move forward when I get the gut feeling I am correct - 4) Most likely because of 1), I usually do not manage to fully explain 3) when it comes true. - 5) I have developed for many years (>18) in many different environments,...
5
2204
by: CreepieDeCrapper | last post by:
i have a simple JS window.open function that i'm calling and it works great here: http://demo.creationsite.com/GLBC/www/ (click on "virtual tour" in the yellow text link) - no status bar - proper title in title bar (same as main window)
6
2651
by: Niklaus | last post by:
Hi, Can someone point out what is wrong with this code ? How can i make it better optimize it. When run it gives me seg fault in linux. But windows it works fine(runs for a long time). Do we have something like stack size growing enormously and then saying you can't access ,so a segfault ? It would be helpful if someone can run the code and give me the output. It takes a long time on my PC.
8
3737
by: Atanas Banov | last post by:
i ran onto this weirdness today: seems like close() on popen-ed (pseudo)file fails miserably with exception instead of returning exit code, when said exit code is -1. here is the simplest example (under Windows): >>> print popen('exit 1').close() 1 >>> print popen('exit -1').close() Traceback (most recent call last):
16
2057
by: LayneMitch | last post by:
Greetings everyone. I'm new to the webdevelopment game and I developed my first site that looks good in IE but crappy in Mozilla/Firefox. Any advice on making my site browser to browser compatible? All I know so far is HTML/CSS, so I won't fair well with Javascript solutions or any other scripting language. I'm going to conquer those next.
2
2404
by: Mirko Vogt | last post by:
Hey, it seems that the socket-module behaves differently on unix / windows when a timeout is set. Here an example: # test.py import socket sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) print 'trying to connect...'
0
832
by: Gabriel Genellina | last post by:
En Wed, 09 Jul 2008 15:02:56 -0300, Mirko Vogt <lists@nanl.deescribi�: Which Python version? Which Windows version? I've tried 2.3.4, 2.4.4, 2.5.1 and 3.0a4, all on WinXP SP2, and in all cases I got an exception (details differ between versions). In no case I could make the connection succeed when nobody was listening at port 9999, as expected. --
0
982
by: Mirko Vogt | last post by:
Gabriel Genellina wrote: Hey, this is strange. Linux: $ python --version Python 2.5.2 $ Windows:
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10259
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.