Thread: output "double" (like 0x1234123412341234) in plain c

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    4

    output "double" (like 0x1234123412341234) in plain c

    hi!

    how can i output an 8-byte-value?

    i basically need to output the result of EDX*0x0000000100000000+EAX (which i extracted from some EDX:EAX value) as plain number (no hex) without dots etc. in plain c language (using code::blocks).

    hopefully you can help!

    thanks in advance,
    delete123

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    What are you even doing?

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    4
    i need to output a "double" in console.

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Yeah, that tells me nothing to be able to help you. If you're trying to read x86 CPU registers from C, you can't do it portably and definitely not in straight C.

  5. #5
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    You want to output a double interpreted as an integer?

  6. #6
    Registered User
    Join Date
    Jun 2008
    Posts
    4
    well. i need to printf("%i", myvalue) where "myvalue" is no "int myvalue" but a "double myvalue". i do not know how to get any clearer.

    i tried with printf("%f", myvalue) but the problem here is that theres ".0000" in the end and the output is not precise.

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    printf("%f", myvalue) is correct.
    Floating point numbers are not entirely precise in C. Language limitation.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    If you need it to be precise, you need to use a library or write your own implementation of simulated, accurate, floating point numbers.

  9. #9
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    To discard the decimals, only printing the integer part of a floating point you can use
    Code:
    "%.0f"

  10. #10
    Registered User
    Join Date
    Jun 2008
    Posts
    4
    exactly. they are not precise enough, thus "%.0f" is not what i need.

    currently i have not the skills to write my own implementation. is there a hint on how i can get this to run in short time?

  11. #11
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Get a library then that supports it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 03:29 PM
  2. Replies: 4
    Last Post: 11-30-2005, 04:44 PM
  3. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  4. Control different DA output value!
    By Hunterhunter in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-13-2003, 12:11 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 05:27 AM