Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Floating Point Formats are not linked

Reply
Thread Tools

Floating Point Formats are not linked

 
 
neha
Guest
Posts: n/a
 
      08-01-2006
hi

Its been Given that Which error are you likely to get when you run the
following program?

main()
{
struct emp
{
char name[20];
float sal;
};
struct emp e[10];
int i;
for(i=0;i<=9;i++)
scanf("%s%f", e[i].name,&e[i].sal);
}

The answer given is Floating point formats are not linked.

so why this error will come ?

 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      08-01-2006
Before I get on to what neha said, I'll make a prediction, based purely on
the subject line. My prediction is that he's using a Borland compiler.

neha said:

> hi
>
> Its been Given that Which error are you likely to get when you run the
> following program?
>
> main()
> {
> struct emp
> {
> char name[20];
> float sal;
> };
> struct emp e[10];


Here's another prediction: if neha adds the following line of code, the
problem will vanish:

double DidBorlandEverFixThisProblem = 3.14159;

> int i;
> for(i=0;i<=9;i++)
> scanf("%s%f", e[i].name,&e[i].sal);
> }
>
> The answer given is Floating point formats are not linked.
>
> so why this error will come ?


Implementation bug, IMHO.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
 
 
 
neha
Guest
Posts: n/a
 
      08-01-2006

Richard Heathfield wrote:
> Before I get on to what neha said, I'll make a prediction, based purely on
> the subject line. My prediction is that he's using a Borland compiler.
>
> neha said:
>
> > hi
> >
> > Its been Given that Which error are you likely to get when you run the
> > following program?
> >
> > main()
> > {
> > struct emp
> > {
> > char name[20];
> > float sal;
> > };
> > struct emp e[10];

>
> Here's another prediction: if neha adds the following line of code, the
> problem will vanish:
>
> double DidBorlandEverFixThisProblem = 3.14159;
>
> > int i;
> > for(i=0;i<=9;i++)
> > scanf("%s%f", e[i].name,&e[i].sal);
> > }
> >
> > The answer given is Floating point formats are not linked.
> >
> > so why this error will come ?

>
> Implementation bug, IMHO.
>
> --
> Richard Heathfield
> "Usenet is a strange place" - dmr 29/7/1999
> http://www.cpax.org.uk
> email: rjh at above domain (but drop the www, obviously)


hi

whts the point in adding this double variable and i want to know when
and why this error" Floating point formats are not linked" usually
comes.

thanks
neha

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      08-01-2006
neha said:

<snip>
>
> hi
>
> whts the point in adding this double variable and i want to know when
> and why this error" Floating point formats are not linked" usually
> comes.


It seems to be a bug in the Borland compiler. I've encountered it a number
of times in the past. Adding the double seems to kick the compiler into
noticing that linking in the math library would be a good plan.

Clearly, adding the double should not be necessary.

Borland has had this bug for a million years or so. It's a great shame,
because the first rule of debugging is "it's my fault - don't blame the
compiler - it's my fault - don't blame the compiler..." but this does
appear to be an exception that can occur all too frequently. Borland also
seems to have an issue with errno, by the way, so watch out for that.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
Dik T. Winter
Guest
Posts: n/a
 
      08-01-2006
In article <(E-Mail Removed) .com> "neha" <(E-Mail Removed)> writes:
> Richard Heathfield wrote:
> > Before I get on to what neha said, I'll make a prediction, based purely on
> > the subject line. My prediction is that he's using a Borland compiler.

....
> > Here's another prediction: if neha adds the following line of code, the
> > problem will vanish:
> >
> > double DidBorlandEverFixThisProblem = 3.14159;

....
> > Implementation bug, IMHO.

....
> whts the point in adding this double variable and i want to know when
> and why this error" Floating point formats are not linked" usually
> comes.


To overcome a well-known bug in a certain compiler.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
 
Reply With Quote
 
neha
Guest
Posts: n/a
 
      08-01-2006

hi


Actaually i have read this prob from the and in the book the reason
given for this error is:

When the compiler encounters a reference to the address of a float it
sets a flag to have the linker link in the floating point emulator.A
floating point emulator is used to manipulate floating point numbers in
runtime library functions like scanf() and atof() .There are some cases
in which the reference to the float is bit obsure and the compiler does
not detect the need for the emulator.

these suitations usually occurs during the intial stages of program
development .Normaly once the prog is fully developed ,the emulator
will be used that the complier can accurately determine when to link
the emulator.

To force linking of the floating piont emulator into an application
just include the following function in your program

void LinkFloat(void)
{
float a=0,*b=&a;
a=*b;
}


so is that mean that whenever this kind of error comes we should force
linking this emulator.wht does this above code do.

 
Reply With Quote
 
Jack Klein
Guest
Posts: n/a
 
      08-01-2006
On 1 Aug 2006 04:17:54 -0700, "neha" <(E-Mail Removed)> wrote in
comp.lang.c:

> hi
>
> Its been Given that Which error are you likely to get when you run the
> following program?
>
> main()
> {
> struct emp
> {
> char name[20];
> float sal;
> };
> struct emp e[10];
> int i;
> for(i=0;i<=9;i++)
> scanf("%s%f", e[i].name,&e[i].sal);
> }
>
> The answer given is Floating point formats are not linked.
>
> so why this error will come ?


How did you miss this question:

"14.13 I'm having trouble with a Turbo C program which crashes and
says something like ``floating point formats not linked.''"

In the FAQ for comp.lang.c when you read it before posting here?

You DID read it before posting here, didn't you?

A link to the FAQ is in my signature. You might find the ANSWER to
the question useful.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
 
Reply With Quote
 
Dik T. Winter
Guest
Posts: n/a
 
      08-02-2006
In article <(E-Mail Removed). com> "neha" <(E-Mail Removed)> writes:
> To force linking of the floating piont emulator into an application
> just include the following function in your program
>
> void LinkFloat(void)
> {
> float a=0,*b=&a;
> a=*b;
> }
>
> so is that mean that whenever this kind of error comes we should force
> linking this emulator.wht does this above code do.


So, because it is documented, it is not a bug, but a feature...
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
 
Reply With Quote
 
neha
Guest
Posts: n/a
 
      08-03-2006

Thanks for the explanations!. Jack it was my mistake i havent read it
before

Neha

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
Accessing array elements via floating point formats. Skybuck Flying C Programming 33 12-17-2010 10:51 PM
Catching floating point errors from linked C code John Pye Python 4 01-25-2007 11:53 PM
floating point problem... floating indeed :( teeshift Ruby 2 12-01-2006 01:16 AM
Floating point formats not linked Ravi C Programming 3 11-08-2003 11:45 PM



Advertisments