Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Use of real types can result in precision problems

Anonymous
Not applicable
I have tried to do some GDL editing and have encountered a script problem under the folowing message:
"Use of real types can result in precision problems at line ..."

What does this mean?
I assume "real types" are normal numbers like 0, 1,2, 3, etc.
Can someone explain the origin of this kind of warning message?
16 REPLIES 16
TomWaltz
Participant
It means that you are using a statement something like:
IF realNumber = 6 THEN
Where this could cause problems if is reaNumber is not actually 6, but is 6.0000001 or 5.9999999. Since it's a real number, that's a perfectly real possibility. Is that were the case, realNumber <> 6, even though it is so close no one could tell the difference.

There was a "preferred method" on this somewhere, in checking if a real number was within a certain range of the preferred value, but I cannot seem to find it.
Tom Waltz
Anonymous
Not applicable
Jaime wrote:
I have tried to do some GDL editing and have encountered a script problem under the folowing message:
"Use of real types can result in precision problems at line ..."
Jaime, the question was discussed in this thread
http://archicad-talk.graphisoft.com/viewtopic.php?t=4677&start=0

additional info here
http://download.graphisoft.com/ftp/techsupport/documentation/developer_docs/BasicLibraryDoc/LibDevGu...
Anonymous
Not applicable
Olivier wrote:
Jaime, the question was discussed in this thread
http://archicad-talk.graphisoft.com/viewtopic.php?t=4677&start=0

additional info here
http://download.graphisoft.com/ftp/techsupport/documentation/developer_docs/BasicLibraryDoc/LibDevGu...
OOPpss! I did not noticed that discussion!
Sorry for the incovenience and thank you for your kind reply!
Anonymous
Not applicable
I was reading "GDL Technical Standards 2"
about this precision issue and read these statements.

"Until ArchiCAD 9, there was only one numeric type, floating point number. You had the possibility to distinguish between some dimension types, but all of them were represented as 'real' numbers.

From ArchiCAD 9 on, the integer inner type was introduced. In connection with the parameter types, the current state is the following: "

What is "integer inner type" ?
I don't see any new parameter types.
In fact, the more times I read these two sentences
the less I understand them.
The first statement I don't understand because there are
two numeric types, integer and floating point.

Comments anyone ?
Peter Devlin
Frank Beister
Moderator
When I read the AC9 documentation I thought, that we are getting real different numeric types. But it seems for me variables are only real integer, if one does not use them in floating point operations. Is that right?
I ever deplored, that all numeric types behave as their declaration only in the parameter list and not inside the script.
In fact, the more times I read these two sentences the less I understand them.
So do I.
The first statement I don't understand because there are two numeric types, integer and floating point.
No. I don't think it means there are two numeric types. It means: There are two types: string and numeric. And numeric is always floting point.

And as I understand the technical standards a numeric type is from AC9 on as long an integer type, as you don't use it in a way it receives a floating point result. I don't see, that this makes things better.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
Hello Frank,
You say in your post:
"No. I don't think it means there are two numeric types. It means: There are two types: string and numeric. And numeric is always floting point."

Is it not true that length, angle, and real number are floating point type
while integer, boolean, material, line type and fill pattern are integer type and text, of course, is a character type or, as you say, string type.

Though Integer is numeric, it is clearly not a floating point because
you are not allowed to type decimal values in the integer field.
Therefor there are two numeric types integer and floating point.
Is this not so ?

You say:
"I ever deplored, that all numeric types behave as their declaration only in the parameter list and not inside the script."
Are you saying that you wish GDL should require in a variable declaration
what the data type is for that variable ?
I always wondered how GDL could function without this.
Peter Devlin
Frank Beister
Moderator
You have to differ between parameters (out of the parameter list) and variables. When a script is started for each parameters will be set a variable. And this can be string (one type) or real (floating point, one type). Try Debugger in edit menu and list all available variables. You will see. That's all ... 'till nine. Since nine it should give real integers. But I have not found any kind of statement to declare them. As I understand the technical standards, variables are as long from type integer, as long you just do integer operations with them (add, subtract, booleans etc.). In the moment you do an operation, which gives a floting point result (e.g. 2+5*PI/1.75) they change back to floating point.

All other parameters, for which it makes no sense, that they are floats, can have a fraction part too .

Define a new pen in the parameter list. Named "CheckPen" try this in 2D-Script:
pen CheckPen
rect2 0,0,0.5,0.5
CheckPen=Checkpen+1.7
pen CheckPen
text2 0,0,CheckPen
In some cases it's very helpful, but if comparations as IF A=12 THEN ... need so horrible constructions as described in tech standards I would prefer to have a basic set of types as string, real, integer, double integer and binary.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Frank Beister
Moderator
Though Integer is numeric, it is clearly not a floating point because
you are not allowed to type decimal values in the integer field.
Therefor there are two numeric types integer and floating point.
Is this not so ?
No, it isn't. As I described before: The parameter list limitations are nothing else than an input mask.

The Plan-Dump shows, that they are stored without fraction part, but the become floating point, when script is running.

SYMBOL 3 {
"Test.7" 86 1 " " 0 "0. Geschoß " 0
"demo_object"
9.7686 0.0347 0.0000 0.00°
1.000000 1.000000
0 0
29
8
"A" 1.0000
"B" 0.2000
"Typ" "Flach"
"D" 2.5000
"penH" 64
"penB" 5
"zzyzx" 0.0000
0.000000 0.000000

PROPERTIES 3 {
}
}
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
Hello Frank,
I did what you suggested and you are absolutely right !
When the script is run the the integer variables are floating point.
I wonder why the ruse or as you say "input mask".

You say:
"As I understand the technical standards, variables are as long from type integer, as long you just do integer operations with them (add, subtract, booleans etc.). In the moment you do an operation, which gives a floting point result (e.g. 2+5*PI/1.75) they change back to floating point."

Another quote from "GDL Technical Standards 2" might explain this.
"GDL variables still don't require type definition, the type is determined
during the interpretation from the value to be loaded into the variable."
Which is exactly what you observed and stated above.

You said:
"but if comparations as IF A=12 THEN ... need so horrible constructions as described in tech standards I would prefer to have a basic set of types as string, real, integer, double integer and binary."

I completely agree, especially now after what you demonstrated to me.
It seems like GS is trying to preserve this no type declaration required "feature" by suggesting these "horrible constructions".

Thank you for showing me the "input mask"
Peter Devlin
P.S.
I still wonder what is "integer inner type"