Floating Point Formats are not linked

N

neha

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.name,&e.sal);
}

The answer given is Floating point formats are not linked.

so why this error will come ?
 
R

Richard Heathfield

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.name,&e.sal);
}

The answer given is Floating point formats are not linked.

so why this error will come ?


Implementation bug, IMHO.
 
N

neha

Richard said:
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.name,&e.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
 
R

Richard Heathfield

neha said:

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.
 
D

Dik T. Winter

....
> 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.
 
N

neha

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.
 
J

Jack Klein

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.name,&e.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.
 
D

Dik T. Winter

> 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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top