3

Is it possible to set this, for example to not have 2.4e+002 but 2.4e2? I really have been searching for this hard, and know how to set with precision the number preceding "e" but the exponent just isn't clear as to what I can do with.No where that I have searched, have I found how to specify this expoenent. I would like to use a integer to specify the number of characters to be presented after "e" and somehow to not include "+" when it is positive, but ofcourse "-" to be included when the exponent is negative.

This is what I want the floating value to be represented in accordance to the following examples:

 134.5 ......  1.345e2
 -21.5 ...... -2.1e1
 -0.005...... 5e-3

By the way, the numbers on the left side of these examples are presented as strings, so I can use that quite easily to bound the number of needed characters left of "e". Could this at all be done using the library functions in C, or should I just right the code myself, which might take some time. Right now, doing printf("%e",fl) will yield too many zeros and un-needed plus sign in the exponent if need be. Anyway to get rid of this in say, less than 20 lines of code using library functions?

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
Roger Federer
  • 329
  • 2
  • 6
  • 12

0 Answers0