Board index » delphi » error 207: Ivalid Floating Point Operator

error 207: Ivalid Floating Point Operator

HI
I'm making this program and out of the blue , without having changed
anything this error came up when I wanted to run it ... Could you
please help??
Here's the program although the load and save procedures are not ready
yet so don't bother with them .
I'm suspecting that a procedure named "closetoV" is responsible for
this because it's dealing with a quadratic but I can't seem to find the
problem. I read about runtime error 207 and it is supposed to point at
a number too big for round to round it . But it's not that because the
number is simply not that big ... Any ideas .. Thanks anyway ...
NoViE

Here it is ... Take a look at it ... It's written in Turbo Pascal for
DOS

program tryopenf;

uses Crt,Graph;

const cMaxnum = 10;

      sPath : string='';

      max = 10;

type rNumbers = record
        question : string;
        answer : real;
     end;

var fSimData : file of rNumbers;

    aFilename : array [1..max] of string;

    anumber : array [1..cMaxnum] of rNumbers;

    gd,gm,gerror : integer;

    choiceB : char;

procedure simquestions;

var  I:integer;

    begin
        for I:=1 to cMaxnum do
            begin
                if I=1 then
                    begin
                        repeat
                            begin
                                clrscr;
                                writeln (aNumber[I].question);
                                readln (aNumber[I].answer);
                            end
                        until  (aNumber[I].answer=1.0) or (aNumber
[I].answer=2.0) or (aNumber[I].answer=3.0);
                    end
                else
                    begin
                        if I in [2,3] then
                            begin
                                repeat
                                    begin
                                        clrscr;
                                        writeln (aNumber[I].question);
                                        readln (aNumber[I].answer);
                                    end
                                until  (aNumber[I].answer=1.0) or
(aNumber[I].answer=2);
                            end
                        else
                            begin
                                clrscr;
                                writeln (aNumber[I].question);
                                readln (aNumber[I].answer);
                            end;
                    end;
               end;
        writeln('press any key to continue...');
        readkey;
    end;

procedure recload;

    begin
        aNumber[1].question:='Analysis: press [a] for m/pixel or [b]
for cm/pixel or [c] for Km/pixel';
        aNumber[2].question:='Type of collision: press [a] for elastic
or [b] for inelastic';
        aNumber[3].question:='Type of motion: press [a] for uniform or
[b] for uniformly accelerated';
        aNumber[4].question:='Give the mass of the first object in Kg';
        aNumber[5].question:='Give the mass of the second object in Kg';
        {aSimB[3].question:='Give the coefficient of friction '};
        aNumber[6].question:='Give the velocity of the first object
before the collision';
        aNumber[7].question:='Give the velocity of the second object
before the collision';
        aNumber[8].question:='Give the distance of first object from
point of reference';
        aNumber[9].question:='Give the distance of second object from
point of reference';
        aNumber[10].question:='Give the distance of the point of
reference from the left end of the screen';
        {aSimB[8].question:='Give the distance of first object from
point of collision after the collision';
        aSimB[9].question:='Give the distance of second object from
point of collision after the collision';}
    end;

procedure load;

var line:string[80];
    tText:text;

    begin
        assign (tText,'a:\dearuser');
        reset(tText);
        while not eof(tText) do
             begin
                 readln (tText,line);
                 writeln (line);
             end;
        readkey;
        clrscr;
    end;

function EI(MA,MB,VAI,VBI:real):real;
    begin
        EI:=((MA*VAI*VAI)/2)+((MB*VBI*VBI)/2);
    end;

function MI (MA,MB,VAI,VBI:real):real;
    begin
        MI:=(ma*VAI)+(mb*VBI);
    end;

function C (MA,MB,VAI,VBI:real):real;
    begin
        C:=-EI(MA,MB,VAI,VBI)+(MI(MA,MB,VAI,VBI)*MI
(MA,MB,VAI,VBI)/(2*MB));
    end;

Function B(MA,MB,VAI,VBI:real):real;
    begin
        B:=MI(MA,MB,VAI,VBI)*MA/MB;
    end;

function A(ma,mb:real):real;
    begin
        A:=(ma/2)+(mA*mA/(2*mB));
    end;

procedure closetoV (var MA,MB,VAI,VBI,VAF,VBF:real);

var D,E,VAFa,VAFb,VBFa,VBFb:real;

    begin
        D:=B(MA,MB,VAI,VBI)*B(MA,MB,VAI,VBI)-4*A(MA,MB)*C
(MA,MB,VAI,VBI);
        if D<0 then
            begin
                writeln ('according to the data you have given the two
objects never collide...')
            end
        else
            begin
                if D=0 then
                    begin
                        VAF:=(-B(MA,MB,VAI,VBI))/(2*A(MA,MB));
                        VBF:=(MI(MA,MB,VAI,VBI)-(MA*VAF))/MB;
                    end
                else
                    begin
                        E:=sqrt(D);
                        VAFa:=(-B(MA,MB,VAI,VBI)+E)/(2*A(MA,MB));
                        VAFb:=(-B(MA,MB,VAI,VBI)-E)/(2*A(MA,MB));
                        VBFa:=(MI(MA,MB,VAI,VBI)-(ma*VAFa))/mb;
                        VBFb:= (MI(MA,MB,VAI,VBI)-(ma*VAFb))/mb;
                        if (VBFa=VBI) and (VAFa=VAI) then
                            begin
                                if (VBFb<>VBI) and (VAFb<>VAI) then
                                    begin
                                        VBF:=VBFb;
                                        VAF:=VAFb;
                                    end;
                            end
                        else
                            if (VBFb=VBI) and (VAFb=VAI) then
                                 begin
                                     VBF:=VBFa;
                                     VAF:=VAFa;
                                 end;
                    end;
            end;
     end;

procedure drawcircle(var rX,rVelocity:real);

var wRadius:word;
    iMaxY:integer;

    begin
        wRadius:=10;
        iMaxY:=getmaxY;
        circle(round(rX),iMaxY div 2,1);
        circle(round(rX),iMaxY div 2,wRadius);
        delay(round(1000/rVelocity));
    end;

procedure setwindow(xx,xy,yy,yx,color:word);
    begin

        window(xx,xy,yy,yx);
        setbkcolor(color);
        clearviewport;
    end;

procedure circlemove (var rDistA,rDistB,rRef:real);

var  rMovA,rMovB,VAF,VBF:real;
     maxX,maxY:integer;
     bKeypressed:boolean;

    begin
        maxX:=getmaxX;
        maxY:=getmaxY;
        rMovA:=rRef+rDistA;
        rMovB:=rRef+rDistB;
        outtext('press any key to start simulation...');
        readkey;
        outtextXY(1,40,'simulating...');
        repeat
            setwindow(1,15,80,16,0);
            if rDistA-rDistB<0  then
                begin
                    rMovA:=rMovA+1;
                    rMovB:=rMovB-1;
                end
            else
                begin
                    rMovA:=rMovA-1;
                    rMovB:=rMovB+1;
                end;
            drawcircle(rMovA,aNumber[6].answer);
            drawcircle(rMovB,aNumber[7].answer);
        until abs(rMova-rMovb)=22;
        outtextXY(1,80,'press any key whenever you wish to stop the
simulation..');
        repeat
            setwindow(1,15,80,16,0);
            if rDistA-rDistB<0 then
                begin
                    rMovA:=rMovA-1;
                    rMovB:=rMovB+1;
                end
            else
                begin
                    rMovA:=rMovA+1;
                    rMovB:=rMovB-1;
                end;
            closetoV(aNumber[4].answer,aNumber[5].answer,aNumber
[6].answer,aNumber[7].answer,VAF,VBF);
            drawcircle(rMovA,VAF);
            drawcircle(rMovB,VBF);
        until (rMovA=maxX) or (rMovA=0) or (rMovB=maxX) or (rMovB=0) or
(keypressed);
        readkey;
        outtext('press any key to exit...');
        readkey;
    end;

procedure pGraph;

var maxx,maxy,x:integer;

    begin
        repeat
            gd:=detect;
            initgraph(gd,gm,sPath);
            gerror:=graphresult;
            if gerror<>grOK then
                begin
                    writeln('Graphics Error:',Grapherrormsg(gerror));
                    if gerror=GrFileNotFound then
                        begin
                            writeln ('Cannot find graphics driver .
Please');
                            write ('Enter directory path for the
driver:');
                            readln (sPath);
                            writeln;
                        end
                    else halt(1)
                end
        until gerror=grok;
        circlemove(aNumber[8].answer,aNumber[9].answer,aNumber
[10].answer);
        closegraph;
    end;

procedure pSave (sFilename:string);

var loop:integer;

    begin
        assign (fSimData,'sFilename');
        rewrite (fSimData);
        for loop:=1 to cMaxNum do
            begin
                write (fSimData,aNumber[loop]);
                close (fSimData);
            end;
    end;

procedure save;

var loop,iLoop: Integer;
    choice: char;
    sPath : string;
    bnamefound:boolean;

    begin
        loop:=0;
        writeln ('Type in the path and the name of the file ...');
        writeln ('It must be given in the form a:\dir1\dir2\name.dat');
        repeat
            loop:=loop+1
        until (loop=max) or (aFilename[loop]='');
        If afilename[loop]='' then
            begin
                readln(aFilename[loop]) ;
                pSave(aFilename[loop]);
            end;
        If (loop=max) and (aFilename[max]<>'') then
            writeln ('This program does not handle more than ',max,'
files.');
            writeln ('It
...

read more »

 

Re:error 207: Ivalid Floating Point Operator


Could you please press CTRL-O two times in the TP IDE?
This will generate two lines with all Compiler options uses as the first
two lines of your code. Please post this, it could help!

Markus

Quote
nove...@my-deja.com wrote:
> HI
> I'm making this program and out of the blue , without having changed
> anything this error came up when I wanted to run it ... Could you
> please help??
> Here's the program although the load and save procedures are not ready
> yet so don't bother with them .
> I'm suspecting that a procedure named "closetoV" is responsible for
> this because it's dealing with a quadratic but I can't seem to find the
> problem. I read about runtime error 207 and it is supposed to point at
> a number too big for round to round it . But it's not that because the
> number is simply not that big ... Any ideas .. Thanks anyway ...
> NoViE

> Here it is ... Take a look at it ... It's written in Turbo Pascal for
> DOS

> program tryopenf;

> uses Crt,Graph;

> const cMaxnum = 10;

>       sPath : string='';

>       max = 10;

> type rNumbers = record
>         question : string;
>         answer : real;
>      end;

> var fSimData : file of rNumbers;

>     aFilename : array [1..max] of string;

>     anumber : array [1..cMaxnum] of rNumbers;

>     gd,gm,gerror : integer;

>     choiceB : char;

> procedure simquestions;

> var  I:integer;

>     begin
>         for I:=1 to cMaxnum do
>             begin
>                 if I=1 then
>                     begin
>                         repeat
>                             begin
>                                 clrscr;
>                                 writeln (aNumber[I].question);
>                                 readln (aNumber[I].answer);
>                             end
>                         until  (aNumber[I].answer=1.0) or (aNumber
> [I].answer=2.0) or (aNumber[I].answer=3.0);
>                     end
>                 else
>                     begin
>                         if I in [2,3] then
>                             begin
>                                 repeat
>                                     begin
>                                         clrscr;
>                                         writeln (aNumber[I].question);
>                                         readln (aNumber[I].answer);
>                                     end
>                                 until  (aNumber[I].answer=1.0) or
> (aNumber[I].answer=2);
>                             end
>                         else
>                             begin
>                                 clrscr;
>                                 writeln (aNumber[I].question);
>                                 readln (aNumber[I].answer);
>                             end;
>                     end;
>                end;
>         writeln('press any key to continue...');
>         readkey;
>     end;

> procedure recload;

>     begin
>         aNumber[1].question:='Analysis: press [a] for m/pixel or [b]
> for cm/pixel or [c] for Km/pixel';
>         aNumber[2].question:='Type of collision: press [a] for elastic
> or [b] for inelastic';
>         aNumber[3].question:='Type of motion: press [a] for uniform or
> [b] for uniformly accelerated';
>         aNumber[4].question:='Give the mass of the first object in Kg';
>         aNumber[5].question:='Give the mass of the second object in Kg';
>         {aSimB[3].question:='Give the coefficient of friction '};
>         aNumber[6].question:='Give the velocity of the first object
> before the collision';
>         aNumber[7].question:='Give the velocity of the second object
> before the collision';
>         aNumber[8].question:='Give the distance of first object from
> point of reference';
>         aNumber[9].question:='Give the distance of second object from
> point of reference';
>         aNumber[10].question:='Give the distance of the point of
> reference from the left end of the screen';
>         {aSimB[8].question:='Give the distance of first object from
> point of collision after the collision';
>         aSimB[9].question:='Give the distance of second object from
> point of collision after the collision';}
>     end;

> procedure load;

> var line:string[80];
>     tText:text;

>     begin
>         assign (tText,'a:\dearuser');
>         reset(tText);
>         while not eof(tText) do
>              begin
>                  readln (tText,line);
>                  writeln (line);
>              end;
>         readkey;
>         clrscr;
>     end;

> function EI(MA,MB,VAI,VBI:real):real;
>     begin
>         EI:=((MA*VAI*VAI)/2)+((MB*VBI*VBI)/2);
>     end;

> function MI (MA,MB,VAI,VBI:real):real;
>     begin
>         MI:=(ma*VAI)+(mb*VBI);
>     end;

> function C (MA,MB,VAI,VBI:real):real;
>     begin
>         C:=-EI(MA,MB,VAI,VBI)+(MI(MA,MB,VAI,VBI)*MI
> (MA,MB,VAI,VBI)/(2*MB));
>     end;

> Function B(MA,MB,VAI,VBI:real):real;
>     begin
>         B:=MI(MA,MB,VAI,VBI)*MA/MB;
>     end;

> function A(ma,mb:real):real;
>     begin
>         A:=(ma/2)+(mA*mA/(2*mB));
>     end;

> procedure closetoV (var MA,MB,VAI,VBI,VAF,VBF:real);

> var D,E,VAFa,VAFb,VBFa,VBFb:real;

>     begin
>         D:=B(MA,MB,VAI,VBI)*B(MA,MB,VAI,VBI)-4*A(MA,MB)*C
> (MA,MB,VAI,VBI);
>         if D<0 then
>             begin
>                 writeln ('according to the data you have given the two
> objects never collide...')
>             end
>         else
>             begin
>                 if D=0 then
>                     begin
>                         VAF:=(-B(MA,MB,VAI,VBI))/(2*A(MA,MB));
>                         VBF:=(MI(MA,MB,VAI,VBI)-(MA*VAF))/MB;
>                     end
>                 else
>                     begin
>                         E:=sqrt(D);
>                         VAFa:=(-B(MA,MB,VAI,VBI)+E)/(2*A(MA,MB));
>                         VAFb:=(-B(MA,MB,VAI,VBI)-E)/(2*A(MA,MB));
>                         VBFa:=(MI(MA,MB,VAI,VBI)-(ma*VAFa))/mb;
>                         VBFb:= (MI(MA,MB,VAI,VBI)-(ma*VAFb))/mb;
>                         if (VBFa=VBI) and (VAFa=VAI) then
>                             begin
>                                 if (VBFb<>VBI) and (VAFb<>VAI) then
>                                     begin
>                                         VBF:=VBFb;
>                                         VAF:=VAFb;
>                                     end;
>                             end
>                         else
>                             if (VBFb=VBI) and (VAFb=VAI) then
>                                  begin
>                                      VBF:=VBFa;
>                                      VAF:=VAFa;
>                                  end;
>                     end;
>             end;
>      end;

> procedure drawcircle(var rX,rVelocity:real);

> var wRadius:word;
>     iMaxY:integer;

>     begin
>         wRadius:=10;
>         iMaxY:=getmaxY;
>         circle(round(rX),iMaxY div 2,1);
>         circle(round(rX),iMaxY div 2,wRadius);
>         delay(round(1000/rVelocity));
>     end;

> procedure setwindow(xx,xy,yy,yx,color:word);
>     begin

>         window(xx,xy,yy,yx);
>         setbkcolor(color);
>         clearviewport;
>     end;

> procedure circlemove (var rDistA,rDistB,rRef:real);

> var  rMovA,rMovB,VAF,VBF:real;
>      maxX,maxY:integer;
>      bKeypressed:boolean;

>     begin
>         maxX:=getmaxX;
>         maxY:=getmaxY;
>         rMovA:=rRef+rDistA;
>         rMovB:=rRef+rDistB;
>         outtext('press any key to start simulation...');
>         readkey;
>         outtextXY(1,40,'simulating...');
>         repeat
>             setwindow(1,15,80,16,0);
>             if rDistA-rDistB<0  then
>                 begin
>                     rMovA:=rMovA+1;
>                     rMovB:=rMovB-1;
>                 end
>             else
>                 begin
>                     rMovA:=rMovA-1;
>                     rMovB:=rMovB+1;
>                 end;
>             drawcircle(rMovA,aNumber[6].answer);
>             drawcircle(rMovB,aNumber[7].answer);
>         until abs(rMova-rMovb)=22;
>         outtextXY(1,80,'press any key whenever you wish to stop the
> simulation..');
>         repeat
>             setwindow(1,15,80,16,0);
>             if rDistA-rDistB<0 then
>                 begin
>                     rMovA:=rMovA-1;
>                     rMovB:=rMovB+1;
>                 end
>             else
>                 begin
>                     rMovA:=rMovA+1;
>                     rMovB:=rMovB-1;
>                 end;
>             closetoV(aNumber[4].answer,aNumber[5].answer,aNumber
> [6].answer,aNumber[7].answer,VAF,VBF);
>             drawcircle(rMovA,VAF);
>             drawcircle(rMovB,VBF);
>         until (rMovA=maxX) or (rMovA=0) or (rMovB=maxX) or (rMovB=0) or
> (keypressed);
>         readkey;
>         outtext('press any key to exit...');
>         readkey;
>     end;

> procedure pGraph;

> var maxx,maxy,x:integer;

>     begin
>         repeat
>             gd:=detect;
>             initgraph(gd,gm,sPath);
>             gerror:=graphresult;
>             if gerror<>grOK then
>                 begin
>                     writeln('Graphics Error:',Grapherrormsg(gerror));
>                     if gerror=GrFileNotFound then
>                         begin
>                             writeln ('Cannot find graphics driver .
> Please');
>                             write ('Enter directory path for the
> driver:');
>                             readln (sPath);
>                             writeln;
>                         end
>                     else halt(1)
>                 end
>         until gerror=grok;
>         circlemove(aNumber[8].answer,aNumber[9].answer,aNumber
> [10].answer);
>         closegraph;
>     end;

> procedure pSave (sFilename:string);

> var loop:integer;

>     begin
>         assign

...

read more »

Re:error 207: Ivalid Floating Point Operator


Quote
Markus Humm wrote:
> Could you please press CTRL-O two times in the TP IDE?

Could you please quote correctly? :-)

Re:error 207: Ivalid Floating Point Operator


[caution: long lines ahead! Apologies to anyone who doesn't like them - I
don't much like them myself, but I don't like putting in linebreaks that may
be confusing. Also apologies if my editor has introduced tab damage
anywhere.]

Quote
nove...@my-deja.com wrote:
> I'm making this program and out of the blue , without having changed
> anything this error came up when I wanted to run it ... Could you
> please help??

I can try; there are also some things you could do to help, such as:

* reporting where the error occurred
* telling us what sample input produced the error
* trying to trim the code to a smaller program that still exhibits the error
* commenting your code so we can see what it's trying to do

The first two of these are probably the most important for tracing errors in
fairly simple programs; the last helps greatly in more complex programs, and
should be done as a matter of course.

I ran your program, and didn't get an error 207. I did often get error 106,
because you prompt the user for a character but use readln to read the
response into a variable of type real.

Quote
> problem. I read about runtime error 207 and it is supposed to point at
> a number too big for round to round it . But it's not that because the
> number is simply not that big ... Any ideas .. Thanks anyway ...

How do you know how big the number is? This is where having sample input is
helpful.

Another point to consider: You have several unnecessary "begin..end" pairs.
Try to trim them. Note that

repeat
  begin
    {statements}
  end
until {condition}

is not necessary, and

repeat
  {statements}
until {condition}

has the same effect. You also often use structures such as

if {condition} then
  begin
    {if-statement}
  end
else
  begin
    {if-statement}
  end;

in which the begin..end pairs can be removed. Remember that an if-then-else
block counts as a single statement.

Nevertheless, there's one spot where you clearly need a begin..end but
didn't put one in. It's in procedure "save", after the line

  if (loop=max) and (aFilename[max]<>'') then

- there are about 25 lines after this that seem as if they should all
belong to this 'if' statement, so you need to put "begin..end" around them.

Here's an example of what I mean: this procedure

Quote
> procedure simquestions;

> var  I:integer;

>     begin
>         for I:=1 to cMaxnum do
>             begin
>                 if I=1 then
>                     begin
>                         repeat
>                             begin
>                                 clrscr;
>                                 writeln (aNumber[I].question);
>                                 readln (aNumber[I].answer);
>                             end
>                         until  (aNumber[I].answer=1.0) or (aNumber
> [I].answer=2.0) or (aNumber[I].answer=3.0);
>                     end
>                 else
>                     begin
>                         if I in [2,3] then
>                             begin
>                                 repeat
>                                     begin
>                                         clrscr;
>                                         writeln (aNumber[I].question);
>                                         readln (aNumber[I].answer);
>                                     end
>                                 until  (aNumber[I].answer=1.0) or
> (aNumber[I].answer=2);
>                             end
>                         else
>                             begin
>                                 clrscr;
>                                 writeln (aNumber[I].question);
>                                 readln (aNumber[I].answer);
>                             end;
>                     end;
>                end;
>         writeln('press any key to continue...');
>         readkey;
>     end;

can be rewritten as follows:

procedure simquestions;

var i: integer;

begin
  for i := 1 to cMaxnum do
    if I=1 then
      repeat
        clrscr;
        writeln (aNumber[I].question);
        readln (aNumber[I].answer);
      until  (aNumber[I].answer=1.0) or (aNumber[I].answer=2.0) or (aNumber[I].answer=3.0);
    else
      if I in [2,3] then
        repeat
          clrscr;
          writeln (aNumber[I].question);
          readln (aNumber[I].answer)
        until  (aNumber[I].answer=1.0) or (aNumber[I].answer=2);
      else
        begin
          clrscr;
          writeln (aNumber[I].question);
          readln (aNumber[I].answer);
        end;
  writeln('press any key to continue...');
  readkey;
end;

This can be made simpler using the case statement:

procedure simquestions;
var i: integer;

begin
  for i := 1 to cMaxnum do
    case i of
      1:
        repeat
          clrscr;
          writeln(aNumber[1].question); {note - we know i is 1 here}
          readln(aNumber[1].answer)
        until (aNumber[1].answer = 1.0) or (aNumber[1].answer = 2.0) or (aNumber[i].answer = 3.0);
      2, 3:
        repeat
          clrscr;
          writeln(aNumber[i].question);
          readln(aNumber[i].answer)
        until (aNumber[1].answer = 1.0) or (aNumber[1].answer = 2.0);
      else
        begin
          clrscr;
          writeln(aNumber[i].question);
          readln(aNumber[i].answer)
        end
    end {case statement}
end;

Now in fact we have the same structure for all of these, so we can simplify
things further, adding in a boolean variable:

procedure simquestions;
var i: integer;
   ok: boolean;

begin
  for i := 1 to cMaxnum do
    repeat
      clrscr;
      writeln(aNumber[i].question);
      readln(aNumber[i].answer);
      case i of
        1: ok := (aNumber[1].answer = 1.0) or (aNumber[1].answer = 2.0) or (aNumber[i].answer = 3.0);
        2, 3: ok := (aNumber[1].answer = 1.0) or (aNumber[1].answer = 2.0);
        else ok := true
      end; {case statement}
    until ok;
end;

There are a few other improvements that can be made, most importantly some
sort of error checking on the input to make sure it converts ok - this means
reading it in as a string value and using Val() to convert it to numeric
form. Of course, you should also change your prompts to match the input
required. 8-)

Quote
> function C (MA,MB,VAI,VBI:real):real;
>     begin
>         C:=-EI(MA,MB,VAI,VBI)+(MI(MA,MB,VAI,VBI)*MI
> (MA,MB,VAI,VBI)/(2*MB));
>     end;

Change this to
  c := -EI(MA, MB, VAI, VBI) + sqr(MI(MA, MB, VAI, VBI) / (2 * MB))
to avoid calling the MI function twice. In fact, you'd be better off
assigning variables MI, EI, A, B and C in your main routine and calculating
their values once only. You're making a lot of unneccesary function calls
re-calculating these quantities.

Hmmmm... after some work, it looks as if you have the correct coefficients -
you're clearly calculating the velocity of A after collision, assuming
elastic collisions.

You should note that D should *never* be negative, since it can be shown
that D = sqr(ma) * sqr(vai - vbi). {Hint: start with your definition of D,
and collect MI^2 terms first; then write MI and EI in terms of the masses
and velocities, expand and collect terms.} This also implies that D will be
zero if and only if vai = vbi (assuming non-zero masses, of course; you
should check to make sure the user enters positive masses).

(in procedure closetoV:)
Note that you get the same numbers in the D=0 case as you do by substituting
D=0 in the formulae for the D>0 case; so it's not necessary to treat D=0
separately.

- Show quoted text -

Quote
>                     begin
>                         E:=sqrt(D);
>                         VAFa:=(-B(MA,MB,VAI,VBI)+E)/(2*A(MA,MB));
>                         VAFb:=(-B(MA,MB,VAI,VBI)-E)/(2*A(MA,MB));
>                         VBFa:=(MI(MA,MB,VAI,VBI)-(ma*VAFa))/mb;
>                         VBFb:= (MI(MA,MB,VAI,VBI)-(ma*VAFb))/mb;
>                         if (VBFa=VBI) and (VAFa=VAI) then
>                             begin
>                                 if (VBFb<>VBI) and (VAFb<>VAI) then
>                                     begin
>                                         VBF:=VBFb;
>                                         VAF:=VAFb;
>                                     end;
>                             end
>                         else
>                             if (VBFb=VBI) and (VAFb=VAI) then
>                                  begin
>                                      VBF:=VBFa;
>                                      VAF:=VAFa;
>                                  end;
>                     end;

This code block can be simplified considerably. Note that once the final
velocity of A is known, VBF is computed by the same formula in each case.
Note also that in any collision, elastic or not, VAF = VAI is equivalent to
VBF = VBI (conservation of momentum - holds in all collisions). So you only
need to check one of these; and furthermore, if you have found that, for
instance, VAFa = VAI (and thus VBFa = VBI) it follows that you should always
pick VAFb and VBFb for the solution. If these are also equal to the initial
values, you're in the D=0 special case, both solutions are the same and it
doesn't matter which one you pick; if not, you always want to pick VAFb and
VBFb. So you may as well always pick them. Finally, we know that the initial
values will always give one solution, so if VAFa <> VAI then we know that
VAFb = VAI and VBFb = VBI; there's no need to check this.

So the code block above can be replaced by the following (also including the
D=0 case):

  begin
    E := sqrt(D);
    VAF := (-B(MA, MB, VAI, VBI) + E) / (2*A(MA, MB));
    if VAF = VAI then  {have wrong solution, use the other one}
      VAF := (-B(MA, MB, VAI, VBI) - E) / (2*A(MA, MB));
    VBF := (MI(MA, MB, VAI, VBI) - MA * VAF) / MB;
  end;

Since D >= 0 is the only case that can arise, your entire procedure can be
replaced by the above code block, with the addition of a line after the
"begin" calculating D.

In procedure drawcircle: wRadius should be a constant. It might be better to
move the delay out of this routine and into the calling routine.

In procedure setwindow: Why are you calling window() in graphics mode?
Perhaps you should check out the help for SetViewport() instead. This
...

read more »

Re:error 207: Ivalid Floating Point Operator


JRS:  In article <3A6600D7.7050...@freenet.de>, seen in
news:comp.lang.pascal.borland, Markus Humm <markus.h...@freenet.de>
wrote at Wed, 17 Jan 2001 21:30:15 :-

Quote
>X-Accept-Language: de, de-de, de-ch, de-at, en, en-$€`

>MIME-Version: 1.0
>X-Complaints-To: ab...@freenet.de
>Lines: 491

>Could you please press CTRL-O two times in the TP IDE?
>This will generate two lines with all Compiler options uses as the first
>two lines of your code. Please post this, it could help!

>Markus

>nove...@my-deja.com wrote:

>> HI
>> I'm making this program and out of the blue , without having changed
>> ..

Your header is still broken, O clueless one.

Please do not quote the whole of a message unless it is essential to do
so.  You have caused about 480 superfluous lines to be sent to every
Usenet news-server in the world, and to be downloaded by many readers of
this newsgroup.  You are deeply inconsiderate - or just plain stupid.
Read via Sig line 3 to find out why, if you do not yet understand.

Novelon :

When posting to News, please indent less deeply and ensure that lines
are not split.

When asking for help on a numerical error, you should say what numbers
you give to it.

You say that you get an RTE 207, but you do not say exactly at what
stage.

Before posting, you should reduce the program as much as possible; it is
very likely, for example, that all calls to the Borland graphics library
could be removed without affecting the problem; and, if it was affected,
which statement did it?

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME ?
  Prof Timo Salmi's Usenet Q&A <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqn.zip>
  TS FAQs via : http://www.uwasa.fi/~ts/http/ : tsfaq.html  quote margin &c.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

Other Threads