??? 04/22/04 05:03 Read: times |
#68993 - RE: double to char Responding to: ???'s previous message |
Sorry, but assuming that you are using double, i guess you have enough space to put in logarithms?
Also, this code will take forever! But, hey, you are working with double precision, what did you expect? Also, i am semi-newbie, forgot to say that on my above post. Do not expect code to work without mods, i am just giving my general ideas. found on random online page (edited to fit): The IEEE double precision floating point standard representation requires a 64 bit word, which may be represented as numbered from 0 to 63, left to right. The first bit is the sign bit, S, the next eleven bits are the exponent bits, 'E', and the final 52 bits are the fraction 'F': S - bit 0 EEEEEEEEEEE - bit 1-11 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -bits 12-63 The format is very simmilar to scientific notation, in fact, i belive it is scientific notation in base two. The mantissa is the decimal part 1.12343, and the exponent is, oviously, the exponent. From this, we can make the following psudocode: print sign if negative. extract Matissa in form of long Print Matissa using print int function above, except put a decimal point after printing the first digit Print an "E" print exponent. That is if you want scientific notation. If you want normal notation, here is my psudocode print sign if negative extract and print Matissa add any zeros to the front or end if necessary insert decimal point into correct location using exponent 2^exponent bits tells how many zeros are necessary, oviously, try to print only the "middle" numbers of double using this method. Use scientific notation for everything else. Finally, if all the exponent bits are on, then there are special considerations If the Matissa is zero the number represents +/- infinity If the Matissa is not zero, the number represents NAN Not regularized is if Matissa is non-zero and Exponent is zero. The rest is up to finding a smarter person than me that can actually give you code :) J/k, i think i gave you enough info so you can do it on your own, this will just take alot of bit shifing and 8 byte manipulation to accomplish. This may be one of the times assembler is better suited for the job, Expect to use r0-r7 on this one :) |
Topic | Author | Date |
double to char | 01/01/70 00:00 | |
RE: double to char | 01/01/70 00:00 | |
RE: double to char | 01/01/70 00:00 | |
RE: double to char | 01/01/70 00:00 | |
RE: double to char | 01/01/70 00:00 | |
RE: double to char | 01/01/70 00:00 | |
RE: double to char | 01/01/70 00:00 | |
RE: double to char![]() | 01/01/70 00:00 |