Float to C double

Bert Freudenberg bert at impara.de
Thu Jun 15 09:28:53 UTC 2006


Am 14.06.2006 um 22:14 schrieb Bruno Luca:

> On Wed, 14 Jun 2006 22:09:17 +0200, Bert Freudenberg  
> <bert at impara.de> wrote:
>
>> Am 14.06.2006 um 21:34 schrieb Bruno Luca:
>>
>>> On Wed, 14 Jun 2006 20:55:07 +0200, Bert Freudenberg  
>>> <bert at impara.de> 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 -




More information about the Squeak-dev mailing list