Forum Jump

Select Group :
Select Forum :
Sorted By :
Sort Order :
From The :
 
Thread Tools  Search this thread 
dannycat
Total Points:
2,535
Status Points:
2,035
Brown Belt
November 20, 2008 5:32 AM PST
GS, GN Format Descriptor

Is there a way of specifying numerical data using a G type descriptor that behaves like ES or EN when the exponential format is required. Currently I believe only the standard E format is used with G specifiers.

eg  -12345.678 in E13.6 format  -0.123456E+05
                         ES13.6 format -1.234567E+04
                         EN13.6 format -12.34567E+03

The ES and EN formats give you an extra significant figure and are easier to read. Using the G format has the advantage of writing numbers in floating point format where possible which are even easier to read. A GS (& GN) format would provide a flexible and neat way of writing a large range of numbers fully utilising the space available.

 

 

tim18
Total Points:
68,267
Status Points:
68,267
Black Belt
November 20, 2008 5:58 AM PST
Rate
 
#1
Quoting - dannycat

Is there a way of specifying numerical data using a G type descriptor that behaves like ES or EN when the exponential format is required. Currently I believe only the standard E format is used with G specifiers.

p edit descriptors may be ugly in some cases, but this is the first time I've seen a claim not to believe in them.



Steve Lionel (Intel)
Total Points:
114,605
Status Points:
114,605
Black Belt
November 20, 2008 3:02 PM PST
Rate
 
#2

As Tim hints, adding 1P (or 2P or whatever) before the G edit descriptor gives you control of the number of digits to the left of the radix point.  There is no S or N form of G.  You will want to make sure that you reset to 0P before using any F edit descriptors.




dannycat
Total Points:
2,535
Status Points:
2,035
Brown Belt
November 21, 2008 4:30 AM PST
Rate
 
#3 Reply to #2

As Tim hints, adding 1P (or 2P or whatever) before the G edit descriptor gives you control of the number of digits to the left of the radix point.  There is no S or N form of G.  You will want to make sure that you reset to 0P before using any F edit descriptors.

Thank Steve, but using the P edit descriptor with G does not do what I requested. I tried it 1PG13.5 for 55.0 example gives a formatted string of 55.00000E+00 not 55.00000. I can get round by coding but the reason for this post was primarily to suggest that the GN and GS format descriptors would be nice to have as part of the language.





Intel Software Network Forums Statistics

8446 users have contributed to 31554 threads and 100402 posts to date.
In the past 24 hours, we have 7 new thread(s) 32 new posts(s), and 43 new user(s).

In the past 3 days, the most popular thread for everyone has been Evaluation of if statements The most posts were made to TBB on linux segfaulting The post with the most views is Quoting - Lorri Menard (In

Please welcome our newest member tconrado