Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Annonces
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

GS, GN Format Descriptor

dannycat
Nouveau contributeur I
919 Visites

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.

0 Compliments
3 Réponses
TimP
Contributeur émérite III
919 Visites
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.

0 Compliments
Steven_L_Intel1
Employé
919 Visites

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.

0 Compliments
dannycat
Nouveau contributeur I
919 Visites

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.

0 Compliments
Répondre