Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6225327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:49:22+00:00 2026-05-24T08:49:22+00:00

Which is the fastest way to convert a byte[] to float[] and vice versa

  • 0

Which is the fastest way to convert a byte[] to float[] and vice versa (without a loop of course).

I’m using BlockCopy now, but then I need the double memory. I would like some kind of cast.

I need to do this conversion just to send the data through a socket and reconstruct the array in the other end.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:49:23+00:00Added an answer on May 24, 2026 at 8:49 am

    Surely msarchet’s proposal makes copies too. You are talking about just changing the way .NET thinks about a memory area, if you dont’ want to copy.

    But, I don’t think what you want is possible, as bytes and floats are represented totally different in memory. A byte uses exactly a byte in memory, but a float uses 4 bytes (32 bits).

    If you don’t have the memory requirements to store your data, just represent the data as the data type you will be using the most in memory, and convert the values you actually use, when you use them.

    How do you want to convert a float (which can represent a value between ±1.5 × 10−45 and±3.4 × 10^38) into a byte (which can represent a value between 0 and 255) anyway?

    (see more info her about:

    • byte: http://msdn.microsoft.com/en-us/library/5bdb6693(v=VS.100).aspx
    • float: http://msdn.microsoft.com/en-us/library/b1e65aza.aspx

    More about floating types in .NET here: http://csharpindepth.com/Articles/General/FloatingPoint.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have mixed data i nvarchar column (words and numbers). Which is fastest way
Using SQL Server, which is the fastest or best practice method to use for
In a recent question I asked about the fastest way to convert a large
Which is generally fastest when reading/comparing row info from a DataTable? 'assume dt as
Suppose you need to run a program on the world’s fastest supercomputer which will
Which way do you prefer to create your forms in MVC? <% Html.Form() {
I'd like to convert a string of text, e.g., User Name into something which
Which of the following code is fastest/best practice for converting some object x? int
I'm curious as to the best way to convert a double to an int.
Is the Visitor Pattern the fastest way to accomplish method parameter type identification (effectively

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.