The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help required on Shell Programming! udiptya UNIX for Dummies Questions & Answers 7 01-31-2008 07:38 AM
Urgent : Help required V3l0 AIX 2 01-11-2008 11:37 AM
Urgent help required umanglalani Shell Programming and Scripting 1 04-12-2007 03:24 AM
Urgent Help required rahul26 UNIX for Dummies Questions & Answers 1 08-16-2006 01:23 PM
Urgent help required with uname() rm1 High Level Programming 2 02-23-2005 10:18 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-31-2002
kkumar1975 kkumar1975 is offline
Registered User
  
 

Join Date: Oct 2001
Posts: 3
Exclamation C programming - Urgent help required

Hi,

I am writing a small 'C' program to add very large floating point numbers. Now the program should be capable of adding the maximum floating point number that is possible on Sun Solaris machine.

Can some let me know whether there is any extra logic that needs to applied for making sure that the program can handle addition of largest floating number that a machine allows.

Thanks,

Last edited by kkumar1975; 03-31-2002 at 01:38 PM..
  #2 (permalink)  
Old 03-31-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
You might want to read this. But the quick answer is as long as you don't overflow, you're ok.
  #3 (permalink)  
Old 04-08-2002
AtleRamsli AtleRamsli is offline
Registered User
  
 

Join Date: Feb 2002
Location: Brabant, Belgium
Posts: 65
If you suspect that your variable may overflow, then I suggest you assume it will.
In programming, Murphy's law is a law of nature :-)
In this case, it would state that 'if a variable _can_ overflow, then there is a 100% chance that it _will_ overflow'

I do not know the actual implementation of floating point under Solaris or other 64 bit OSes, but it would make sense to assume that they are 64 bits in length. This is quite easy to find out, so I assume you will if you don't already know.

Before reading any of this, look for a bignum library, that may have what you need.


If a double is stored in 64 bits, then you could overcome the problem by creating your own 128bit bigfloat

struct bigfloat {
long m; // Mantissa
long e; // Exponent
};

and define the operations you need on bigfloat:

bigfloat bigfloat_add(bigfloat a, bigfloat b)

etc.

This is only one of several approaches, another is to not use float at all, but BCD or even arbitrary length strings.

I don't know what it is that you want to do, if it is some scientific experiment, then just disregard the rest of this.

But in certain applications the use of floating point is illegal!

If I am not mistaken these include safety-critical applications and accounting systems.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0