Thread: Shift exponent and comma to match (normalize)

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    13

    Shift exponent and comma to match (normalize)

    How can I Normalize two float numbers


    Suppose the input of users as this

    1.98 x 10E 4 = 19800
    21.22 x 10E5 = 2120000

    But I need to set them as

    0.19 x 10 E -5
    and the second one must be 0 in the first digit and must be the same exponent
    0.2122 x 10E-6 -> as this is greater than first I must move the coma of the first one

    0.019 x 10 E -6
    0.2122 x 10 E -6

    I need to make this in a single function

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    You can try looking at this thread

    http://cboard.cprogramming.com/showthread.php?t=64322

    or if that doesn't help, maybe this thread will

    http://cboard.cprogramming.com/showthread.php?t=64351

    and, if all else fails, try

    http://cboard.cprogramming.com/showthread.php?t=64350
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    13
    Very Funny.

  4. #4
    Chief Code Coloniser!
    Join Date
    Apr 2005
    Posts
    121
    He's trying to tell you in a very nice way....

    ... DO NOT CROSSPOST OR DOUBLEPOST.

    One question... one thread.

    I mean that in the nicest possible way

  5. #5
    Registered User
    Join Date
    Apr 2005
    Posts
    13
    Did somebody answer on the other posts?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Did somebody answer on the other posts?
    Doesn't look like it - but not getting an answer is not an excuse to spam the board with the same question over and over, without showing any signs of actual progress.

    Consider http://www.opengroup.org/onlinepubs/...xsh/frexp.html
    And comparing the exponents of both floats (say -4 and -7)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Apr 2005
    Posts
    13
    Thanks

Popular pages Recent additions subscribe to a feed