[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: perl binær konvertering



On Wed, 06 Jul 2005 18:45:34 +0200, Rune wrote:

> Jeg har gemt en fil fra et C-program hvor jeg har gemt en masse floats. Før
> jeg gemte floats'ne konverterede jeg dem med reinterpret_cast<long> og
> derefter med ntohl for at få gemt dem som big-endian. Kan man i perl trække
> dataen ud igen dvs anvende hvad der svarer til htonl og derefter
> reinterpret_cast<float> ? 

Måske ved hjælp af 'pack'/'unpack'?

Alt efter hvad din definition af "en masse" er, kan det være nemmere
at lave et C-program der spytter tallene ud i plain text - da perldoc
-f pack si'r:

 "*       Real numbers (floats and doubles) are in the native
          machine format only; due to the multiplicity of floating
          formats around, and the lack of a standard "network"
          representation, no facility for interchange has been made. 
          This means that packed floating point data written on one
          machine may not be readable on another - even if both use
          IEEE floating point arithmetic (as the endian-ness of the
          memory representation is not part of the IEEE spec). See
          also perlport."


  Mvh.

-- 
 "Mr. Cotton's... parrot. Same question."                     Adam Sjøgren
                                                         sslug@sslug


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *