BitConverter DoubleToInt64Bits and Int64BitsToDouble ?

  • Thread starter Thread starter Carl Rosenberger
  • Start date Start date
C

Carl Rosenberger

Hi all,

I need the above two methods to convert double to long and back
on the CompactFramework, preferrably with good performance.

I really like the idea of using a StructLayout with two members
at the same position that I found here:


Apparently the FieldOffset attribute does not seem to be available
on CF. I find that quite strange, since the documentation states
that LayoutKind.Explicit is supported.

Any ideas, options, hints?


Fast bitshifting code to convert a double to long and back would
be a great help also.

Thanks in advance.


Kind regards,
Carl
 
Carl said:
Fast bitshifting code to convert a double to long and back would
be a great help also.

I solved this problem for myself:

For the moment I can live with BitConverter.GetBytes and
the BitConverter.To[xxx] routines.

They might not be the fastest solution but "optimise late"
usually spares a lot of work.

I still would be grateful for faster solutions.

Thanks.

Kind regards,
Carl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top