Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. directly changing the exponent of a type double

directly changing the exponent of a type double

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Filip Govaerts
    wrote on last edited by
    #1

    Hi, Can anyone tell me how to change the exponent from the type double? Basicly what I want to do is to extract the exponent form: <--------------------all the bytes(8 total)-------------------> (SXXX XXXX) (XXXX MMMM) (MMMM MMMM) (MMMM MMMM) ... (MMMM MMMM) (where x represents the exponent) do some calculations and place it back in. I want to this with a large amount of numbers so I seek a pretty fast way to do it. Anyone got an idea? thx already. greetings, Filip Govaerts Belgium

    J 1 Reply Last reply
    0
    • F Filip Govaerts

      Hi, Can anyone tell me how to change the exponent from the type double? Basicly what I want to do is to extract the exponent form: <--------------------all the bytes(8 total)-------------------> (SXXX XXXX) (XXXX MMMM) (MMMM MMMM) (MMMM MMMM) ... (MMMM MMMM) (where x represents the exponent) do some calculations and place it back in. I want to this with a large amount of numbers so I seek a pretty fast way to do it. Anyone got an idea? thx already. greetings, Filip Govaerts Belgium

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      double d;
      unsigned char * d_layout=reinterpret_cast<unsigned char *>(&d);
      //extraction
      int exp=int(d_layout[6]>>4)+(int(d_layout[7]&0x7FU)<<4);
      //insertion
      d_layout[6]&=0x0FU;
      d_layout[6]|=(exp&0x0F)<<4;
      d_layout[7]&=0x80U;
      d_layout[7]|=(exp&0x7F0)>>4;

      Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      F 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        double d;
        unsigned char * d_layout=reinterpret_cast<unsigned char *>(&d);
        //extraction
        int exp=int(d_layout[6]>>4)+(int(d_layout[7]&0x7FU)<<4);
        //insertion
        d_layout[6]&=0x0FU;
        d_layout[6]|=(exp&0x0F)<<4;
        d_layout[7]&=0x80U;
        d_layout[7]|=(exp&0x7F0)>>4;

        Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        F Offline
        F Offline
        Filip Govaerts
        wrote on last edited by
        #3

        respect... thx a lot Filip Govaerts

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups