Hello,
i need to pass a double to a primitive, is Float good for this job? Bye. -- www.lethalman.net - Thoughts about internet technologies |
Am 14.06.2006 um 20:29 schrieb Bruno Luca:
> Hello, > i need to pass a double to a primitive, is Float good for this job? Yes. Squeak Floats are double precision IEEE numbers (FloatArrays are single precision, though). - Bert - |
On Wed, 14 Jun 2006 20:55:07 +0200, Bert Freudenberg <[hidden email]>
wrote: > Yes. Squeak Floats are double precision IEEE numbers So if i need to pass a C float i need to call the primitive with a FloatArray? -- www.lethalman.net - Thoughts about internet technologies |
Am 14.06.2006 um 21:34 schrieb Bruno Luca:
> On Wed, 14 Jun 2006 20:55:07 +0200, Bert Freudenberg > <[hidden email]> wrote: > >> Yes. Squeak Floats are double precision IEEE numbers > > So if i need to pass a C float i need to call the primitive with a > FloatArray? No. In the case of FFI, it converts from Squeak Floats to doubles or floats as necessary depending on the ffi function declaration. If you write a plugin, you just read a double from the stack and call the function with a float, the conversion is inserted by the C compiler. - Bert - |
On Wed, 14 Jun 2006 22:09:17 +0200, Bert Freudenberg <[hidden email]>
wrote: > Am 14.06.2006 um 21:34 schrieb Bruno Luca: > >> On Wed, 14 Jun 2006 20:55:07 +0200, Bert Freudenberg <[hidden email]> >> wrote: >> >>> Yes. Squeak Floats are double precision IEEE numbers >> >> So if i need to pass a C float i need to call the primitive with a >> FloatArray? > > No. In the case of FFI, it converts from Squeak Floats to doubles or > floats as necessary depending on the ffi function declaration. If you > write a plugin, you just read a double from the stack and call the > function with a float, the conversion is inserted by the C compiler. > > - Bert - > > I'm using this syntax: primitiveBla: aFloat boh: aDouble self primitive: 'primitiveBla' parameters: #(Float Float) Is that ok? What about converting a double to a FloatObj? -- www.lethalman.net - Thoughts about internet technologies |
Am 14.06.2006 um 22:14 schrieb Bruno Luca: > On Wed, 14 Jun 2006 22:09:17 +0200, Bert Freudenberg > <[hidden email]> wrote: > >> Am 14.06.2006 um 21:34 schrieb Bruno Luca: >> >>> On Wed, 14 Jun 2006 20:55:07 +0200, Bert Freudenberg >>> <[hidden email]> wrote: >>> >>>> Yes. Squeak Floats are double precision IEEE numbers >>> >>> So if i need to pass a C float i need to call the primitive with >>> a FloatArray? >> >> No. In the case of FFI, it converts from Squeak Floats to doubles >> or floats as necessary depending on the ffi function declaration. >> If you write a plugin, you just read a double from the stack and >> call the function with a float, the conversion is inserted by the >> C compiler. >> >> - Bert - > > I'm using this syntax: > primitiveBla: aFloat boh: aDouble > self primitive: 'primitiveBla' parameters: #(Float Float) > > Is that ok? I think it is, but you should look at the generated code to chck that indeed the right conversion is performed: aDouble := interpreterProxy floatValueOf: aFloatOop > What about converting a double to a FloatObj? aFloatOop := interpreterProxy floatObjectOf: aDouble Bert - |
On Thu, 15 Jun 2006 11:28:53 +0200, Bert Freudenberg <[hidden email]>
wrote: > > Am 14.06.2006 um 22:14 schrieb Bruno Luca: > >> On Wed, 14 Jun 2006 22:09:17 +0200, Bert Freudenberg <[hidden email]> >> wrote: >> >>> Am 14.06.2006 um 21:34 schrieb Bruno Luca: >>> >>>> On Wed, 14 Jun 2006 20:55:07 +0200, Bert Freudenberg <[hidden email]> >>>> wrote: >>>> >>>>> Yes. Squeak Floats are double precision IEEE numbers >>>> >>>> So if i need to pass a C float i need to call the primitive with a >>>> FloatArray? >>> >>> No. In the case of FFI, it converts from Squeak Floats to doubles or >>> floats as necessary depending on the ffi function declaration. If you >>> write a plugin, you just read a double from the stack and call the >>> function with a float, the conversion is inserted by the C compiler. >>> >>> - Bert - >> >> I'm using this syntax: >> primitiveBla: aFloat boh: aDouble >> self primitive: 'primitiveBla' parameters: #(Float Float) >> >> Is that ok? > > I think it is, but you should look at the generated code to chck that > indeed the right conversion is performed: > > aDouble := interpreterProxy floatValueOf: aFloatOop > >> What about converting a double to a FloatObj? > > aFloatOop := interpreterProxy floatObjectOf: aDouble > > Bert - > > Really thanks. Bye :) -- www.lethalman.net - Thoughts about internet technologies |
Free forum by Nabble | Edit this page |