The DataCAD Developer Network (DDN) is an online resource for information and support for DCAL® (DataCAD Applications Language) developers as well as anyone interested in creating fonts, toolbars, hatch patterns, or linetypes for use in DataCAD.
#27780 by Jsosnowski
Fri Sep 07, 2007 10:20 am
I am experiencing a hell of a problem!

Note the following code:
Const
MetricFactor = 1259.84252; {DataCad to imperial to metric}

VAR
WorkStr : str255;
debugRl : real;

A point is initialized with these settings:
RelPnt.x := 433000.0;
RelPnt.y := 7712000.0;
RelPnt.z := 0.0;
Surveyvec is an array of records that includes a point in the location field.

And runs through this code: (note line numbers at end of each line for reference)

Reportstr (‘ X = ‘); !1
Reportstr (‘String: ‘); !2
Reportstr (workstr); !3
IF cvstrll (workstr, surveyvec [1].location.x) THEN !4
Reportstr (‘, Converted Loc.x: ‘); !5
reportdis (surveyvec [1].location.x*metricfactor); !6
surveyvec [1].location.x := (surveyvec [1].location.x – RelPnt.x)* metricfactor; !7
END; !8
Reportstr (‘, RelPnt.x: ‘); !9
Reportdis (relpnt.x*metricfactor); !10
Reportstr (‘, Adjusted Loc.x: ‘); !11
reportdis (surveyvec [1].location.x); !12
Reportstr (‘ metricfactor= ‘); !13
Debugrl := metricfactor; !14
Reportdis (debugRl); !15
Reportstr (‘ 32,800 meter = ‘); !16
Debugrl := 32800.0; !17
DebugRl := debugRl * metricfactor; !18
Reportdis(debugRl); !19
Reportshow; !20

The procedures reportstr, reportdis etc. are similar to utilities in the wrtutl module, except they write to a file instead of the screen. They do not affect the math error I found.

Yields the following in the report file:
X = String: 433847.493,
Converted Loc.x: 433847.487 m,
RelPnt.x: 25751.999 m,
Adjusted Loc.x: 459599.48 m
metricfactor= 1.00 m
32,800 meter = 32735.999 m

The workstr variable reads from a file. Notice that the conversion is handled correctly. RelPnt.x is not handled correctly given an incorrect answer. Also notice that it is adding to the Loc.x variable instead of deducting as is established in the formula. I then tested metricfactor which is correctly reported as one meter. Any multiplication to the metric factor up to 32760 (the limit of an integer) is handled correctly. Once the multiplier surpasses 32760 it begins to deduct instead of add to the value. Note that the variable debugRl handles multiplication in line 18 the same way location does in line 12, but one has the error, and the other does not.

Comments?
#27804 by ERT
Fri Sep 07, 2007 3:23 pm
DataCAD old DCAL real type length 4 byte same Delphi Single type.

Delphi real types:
Type
Range
Significant digits
Size in bytes

Real48
2.9 x 10^-39 .. 1.7 x 10^38
11-12
6

Single
1.5 x 10^-45 .. 3.4 x 10^38
7-8
4

Double
5.0 x 10^-324 .. 1.7 x 10^308
15-16
8

Extended
3.6 x 10^-4951 .. 1.1 x 10^4932
19-20
10

DCAL real = Delphi Single: Significant digits 7-8!!!!!!
This is a problem.

DCAD 9: single precision database: real type is single, 7-8 digits
DCAD11: double precision database: real type is double, 15-16 digits
#27823 by ERT
Sat Sep 08, 2007 12:00 pm
When I worked with older DCAL (DCAD 6-7 ver.), I did the next:
I put my data to file,
execute external program (I wrote it in Turbo Pascal)
the external program calculate and put result to a file
external program finished, back retun to dcal and read the result from the file.

Sorry for my bad english language.
#27843 by Jsosnowski
Mon Sep 10, 2007 9:50 am
Thank You ERT for your response. The numbers I am working with are quite large and so this is a problem I will work on. The other interesting aspect of this is the lines regarding metricfactor. That is a constant numer set to 1259.84 +/-. When I multiply it by nubers up to 32760.0 (the maximum size of an integer) the math is correct. As soon as I exceed this number the math errors, reducing the value by 32760-x where x is the value that exceeds 32760. This suggests that the multiplication process is using an integer somewhere in the process. I find that surprising. MAybe this is inherent in the process of manipulating floats, but that does not seem reasonable .

I have a new V12 coming, so I will play with the macro then. The problem will be, that this code is legacy which is limited to the "real" size.

Who is online

Users browsing this forum: No registered users and 16 guests

About DataCAD Forum

The DataCAD Forum is a FREE online community we provide to enhance your experience with DataCAD.

We hope you'll visit often to get answers, share ideas, and interact with other DataCAD users around the world.

DataCAD

Software for Architects Since 1984