![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help required on Shell Programming! | udiptya | UNIX for Dummies Questions & Answers | 7 | 01-31-2008 03:38 AM |
| Urgent : Help required | V3l0 | AIX | 2 | 01-11-2008 07:37 AM |
| Urgent help required | umanglalani | Shell Programming and Scripting | 1 | 04-12-2007 12:24 AM |
| Urgent Help required | rahul26 | UNIX for Dummies Questions & Answers | 1 | 08-16-2006 10:23 AM |
| Urgent help required with uname() | rm1 | High Level Programming | 2 | 02-23-2005 06:18 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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 10:38 AM. |
| Forum Sponsor | ||
|
|
|
|||
|
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.
__________________
PS All of the above is to be read as '... unless I am wrong' ENDPS |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|