Foreign types in Allegro CL
From: Craig Sauer (craig.sauer_at_gmail.com)
Date: 11/24/04
- Next message: Christophe Rhodes: "Re: Floating-point arithmetic in CL"
- Previous message: Peter Ashford: "Re: C++ sucks for games.... oh really?"
- Next in thread: Kenny Tilton: "Re: Foreign types in Allegro CL"
- Reply: Kenny Tilton: "Re: Foreign types in Allegro CL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 24 Nov 2004 14:14:05 -0800
I'm fairly new to Lisp, and this is my first posting here. I'd
appreciate any advice on this problem I'm having:
I'm passing data back and forth between two applications (currently
both on the same computer) via UDP.
The Lisp program needs to receive a packet of 16 bytes, consisting of
an integer, a double, and another integer. I am receiving the packet
just fine, and I can print out each byte's value individually.
I'm using Allegro CL's foreign types facility, with commands like:
(setf int1test (ff:fslot-value-typed :int :lisp (subseq data 0 4)))
(setf doubletest (ff:fslot-value-typed :double :lisp (subseq data 4
12)))
(setf int2test (ff:fslot-value-typed :int :lisp (subseq data 12)))
to convert the 16 bytes in "data" into the int, double, int, that I'm
expecting.
When I print out these 3 values, using code like:
(format t "~D " int1test)
(format t "~F " doubletest)
(format t "~D~%" int2test)
The integers print out fine, but the double is unrecognizable. I've
tried swapping the bytes in case there is an endian issue at work (but
I doubt it because the integers are ok).
An example:
I send 5, 7.0, 10 ten times
the Lisp program responds: (the third line of every set is the 16
bytes)
Packet 1 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
Packet 2 ->16 bytes from 2130706433
5 -1.6958247478583448d+216 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
Packet 3 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
Packet 4 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
Packet 5 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
Packet 6 ->16 bytes from 2130706433
5 1.5069781534728802d-154 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
Packet 7 ->16 bytes from 2130706433
5 -6.591781867590727d-213 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
Packet 8 ->16 bytes from 2130706433
5 1.4951352948556237d-154 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
Packet 9 ->16 bytes from 2130706433
5 5.31405562d-315 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
Packet 10 ->16 bytes from 2130706433
5 -5.880343017059636d-39 10
5 0 0 0 0 0 0 0 0 0 1c 40 a 0 0 0
I can see that the 16 bytes are the same on each cycle, but I'm
getting a different (incorrect) double on every cycle.
I would appreciate any help on this problem.
Sincerely,
Craig Sauer
- Next message: Christophe Rhodes: "Re: Floating-point arithmetic in CL"
- Previous message: Peter Ashford: "Re: C++ sucks for games.... oh really?"
- Next in thread: Kenny Tilton: "Re: Foreign types in Allegro CL"
- Reply: Kenny Tilton: "Re: Foreign types in Allegro CL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|