Solved

Borland 4.02 Floating Point Overflow Error

Posted on 1997-07-20
6
673 Views
Last Modified: 2012-05-04
I'm new to C++ programming and recently purchased the C++ Starter Kitfrom Sam's publishing for a C++ class I'm taking. The "kit" comes with the Borland C++ compiler v. 4.02, a book and a bunch of info on CD-ROM.  The problem is I'm having trouble entering real numbers into float variables.  For example:

#include <iostream.h>

void main ()
{
float z;
cout << "Enter a real number: ";
cin >> z;
cout << "The nuber is: " << z << endl;
}

The above program will compile and even run as long as an integer is entered.  But, if a real number is entered (ie. 1.2) a run-time error "Floating Point: Overflow" occurs.  I can assign real numbers in the program, but not enter them from the terminal.  Even more strange is that I installed the compiler on my laptop and the program runs fine.
The technical support for SAMs publishing have no idea what's going on and I think Borland charges for technical support.  I suspect that there is a problem with the compiler setup.  Can anyone out there helpme.  My desktop has a Cyrix 6x86-100 (P120+) and the laptop an Intel
P120.  

Thanks,
Mark
0
Comment
Question by:mshuman
6 Comments
 
LVL 4

Expert Comment

by:AVaulin
ID: 1165436
Try use double z;
0
 
LVL 1

Accepted Solution

by:
8051 earned 200 total points
ID: 1165437
I compiled your program in BC 3.1. It works
exactly as you want. I think, proble can be
in compiler settings. In some nearest minutes
I'll put here compiler setup.

Regards
0
 
LVL 1

Expert Comment

by:8051
ID: 1165438
OK, go menu->options->compiler->advanced code generation.
1. Floating Point    (*) 287/387
2. Instruction Set   (*) 386
3. Options           [v] Fast floating point

It works perfect.

Regards

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:mshuman
ID: 1165439
My compiler (Borland 4.02) doesn't have the same options that yours does.  But, I've tried every combination of CPU and floating point options there are.  Also, I've been doing some research... The error only occurs if I compile the program as an EasyWin executable, if I compile it as a standard DOS executable the program executes without the error.  Another strange thing is that I have compiled the program as an EasyWin executable and have run the program on a number of other computers running either Win 3.1 or Win 95 and all have run the program without a problem -- though I cannot run it on the computer on which it was compiled.  Again the error only occurs if a real number is entered.  If I enter an integer, the program works.

Mark
0
 

Author Comment

by:mshuman
ID: 1165440
Oh well, I figured out the problem myself. Here's how, because I don't think anyone could have done this without being at my computer.  
1.  Started Win 95 in Safe Mode - program ran without error
2.  Started Win 95 by with step-by-step confirmation
    a.  No registry load - program had error
    b.  No config.sys - program had error
    c.  No windows drivers - no error
3.  Start Windows 95 in normal mode and ran program after removing programs from memory (cntrl-alt-del to see programs)...
Program ran without error after removing em_exec.exe (Logitech trackball driver), started em_exec.exe again -- program had error.
4.  Therefore program somehow conflicts with Logitech Trackball Driver -- I'm going to contact Logitech now.

Thanks for your help,

Mark

0
 

Expert Comment

by:dclane
ID: 1165441
In Floating point ( and all variables ) you must 'scope' your variables if that does not work.  Try Math control functions.

DCLANE
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now