[fpc-devel] StrPos giving a access violation

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Dec 12 14:02:41 CET 2005


On 12 dec 2005, at 13:57, Micha Nelissen wrote:

>> It happens in more in Pascal. For example, single(longint_var) is   
>> also not the same as single(pointer(longint_var)) (let's assume a   
>> 32bit system). In the former case, the longint is convert to a   
>> floating point number with the same value. In the latter case,  
>> you  get a floating point number with the same bit pattern as  
>> that  original longint (which may be a valid or invalid floating  
>> point  number, and whose value is almost certainly different from  
>> the  longint's value, except in case of 0).
>
> Oh, I thought always the second case happened. Apparantly not.

No, otherwise an implicit type conversion (e.g. passing a longint to  
a function which expects a floating point parameter) and an explicit  
typecase (as above) would have different results. Implicit type  
conversions are not always allowed (because of type safety), but when  
they are allowed they have the same effect as an explicit typecast.


Jonas



More information about the fpc-devel mailing list