1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bit operations on different datatypes

Discussion in 'C' started by jipe4153, Sep 8, 2010.

  1. jipe4153

    jipe4153 New Member

    Joined:
    Sep 8, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello,

    I've written som code that parses through an array of chars and performs bit operations on each char ( each byte).

    Now what i would like to do is to reuse this code to parse through all of the bytes of an array of floats and perform those very same bit operations on each byte.

    How to best go about this?

    If i have my float array:

    float* float_array = (float*)malloc(...);

    can i then just do:

    unsigned char* char_array = (unsigned char*)(float_array);

    And just reuse my old code?

    Any advice would be much appreciated! Thanks!
     

Share This Page