Streaming floating point
-
- Registered: Oct 30, 2008
- Last visit: Mar 18, 2009
- Posts: 10
Hi
When I try to write a floating point value to a stream, I get an access violation in the system unit (line 13909, the move procedure).
Example code :
Code
var
f : Extended;
fst : tmemorystream;
Begin
fst := tmemorystream.create;
f := 1.123;
fst.write(f,sizeof(f));
end;
Kim Foder -
- Registered: Dec 24, 2008
- Last visit: Feb 05, 2010
- Posts: 15
Hi Kim,
that is an really interesting problem! The main problem is the system.move procedure, which fails indeed. You may use the following testcode:
Code
var a,b ; DataType;
begin
a := <value>;
system.move(a,b,sizeof(a));
writeln (b);
where datatype is some kind of type. This Code will work with all kind of types i have tested, e.g. WORD, String, but it will not work with any kind of floating-point types including EXTENDED! A workaround in this cases is to use a typecast to POINTER:
Code
var a,b ; Extended;
begin
a := 1.123;
system.move(POINTER(a),POINTER(b),sizeof(a));
writeln (b);
This solves the problem, but I don't know why!
Regards Peter -
- Registered: Dec 24, 2008
- Last visit: Feb 05, 2010
- Posts: 15
Hi Kim,
in the unit system.pas the line containing
PROCEDURE Move(CONST source; VAR dest; size:LONGWORD);
must be changed to
PROCEDURE Move(VAR source; VAR dest; size:LONGWORD);
and everything works fine ;-) This must be done in the interface and the implementation part.
Regards Peter
editiert von: pengels, 19.01.2009, 18:07 Uhr -
- Registered: Dec 04, 2006
- Last visit: Dec 29, 2011
- Posts: 89
-
- Registered: Dec 24, 2008
- Last visit: Feb 05, 2010
- Posts: 15
Hi Kim,
an additional note: In order to solve your problem completely, you must change the calling conventions of writing-routines in uStram.pas in the same way described: change the keyword CONST to VAR and everything will work ok. But you have to rebuild the complete Library.
Regards Peter. -
- Registered: Feb 07, 2008
- Last visit: Jan 30, 2011
- Posts: 19
I cannot find how to recompile the complete library. Can I get a heads up on how to do this from someone who already knows?
-Mark
-- Ok, perhaps this is what I needed to know:
Change the SYSTEM.PAS file in the MakeRTL project.
Save the change.
Recompile the project.
Should I figure out how to force recompile the whole RTL?
edited by: Mark, Jan 24, 2009 - 05:54 PM
Regards, -
- Registered: Dec 04, 2006
- Last visit: Dec 29, 2011
- Posts: 89
Hello!
You can compile the library with the programs:
for OS/2:
..\WDSibyl\Tools\Output\OS2\COMPILEALLRC.exe
..\WDSibyl\Tools\Output\OS2\COMPILEALLPAS.exe
for Win32:
..\WDSibyl\Tools\Output\Win32\COMPILEALLRC.exe
..\WDSibyl\Tools\Output\Win32\COMPILEALLPAS.exe
In this directories you find the Log-Files too.
This programs are used by the installatons.
bye,
Wolfgang -
- Registered: Oct 30, 2008
- Last visit: Mar 18, 2009
- Posts: 10
Hi Peter
Sory for the dalay, I have been busy elsewhere.
Quote
A workaround in this cases is to use a typecast to POINTER:
Yes I'm using something like this my self, only problem has been my memory, after some time I forget about the problem, and then wastes hours on debugging :-(
Great you have found the reason, thanks.
I am somewhat mystified by the problem, shouldn't a var and a const parameter in reality both be pointers ?
KIm
- Moderated by:
- Admins-Forum
Users on-line
- 0 users
This list is based on users active over the last 30 minutes.