User Tools

Site Tools


cpp:osteams

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
cpp:osteams [2020/05/17 18:16]
gthanos
cpp:osteams [2020/05/17 19:10]
gthanos [std::ios::floatfield]
Line 48: Line 48:
 int main() { int main() {
   cout.setf(std::ios::hex, std::ios::basefield);   cout.setf(std::ios::hex, std::ios::basefield);
-  cout << 16 << endl;+  cout << "0x" <<16 << endl;
 } }
 </code> </code>
Line 155: Line 155:
      
   /* no special formatting specified */   /* no special formatting specified */
 +  cout << 0.00000123456789012345678 << endl;
 +  cout << 0.0000123456789012345678 << endl;
 +  cout << 0.000123456789012345678 << endl;
 +  cout << 0.00123456789012345678 << endl;
 +  cout << 0.0123456789012345678 << endl;
   cout << 0.123456789012345678 << endl;   cout << 0.123456789012345678 << endl;
   cout << 123.4567890123456789 << endl;   cout << 123.4567890123456789 << endl;
Line 160: Line 165:
   cout << 123456789.0123456789 << endl;   cout << 123456789.0123456789 << endl;
      
-  cout << fixed << endl; +  cout << std::showpoint << endl;
-  cout << setprecision(1) << 123.456 << endl; +
-  cout << setprecision(2) << 123.456 << endl; +
-  cout << setprecision(3) << 123.456 << endl; +
-  cout << setprecision(4) << 123.456 << endl; +
-  cout << setprecision(5) << 123.456 << endl; +
-  cout << setprecision(6) << 123.456 << endl; +
-  cout << setprecision(7) << 123.456 << endl; +
-   +
-  cout << scientific << endl; +
-  cout << setprecision(1) << 123.456 << endl; +
-  cout << setprecision(2) << 123.456 << endl; +
-  cout << setprecision(3) << 123.456 << endl; +
-  cout << setprecision(4) << 123.456 << endl; +
-  cout << setprecision(5) << 123.456 << endl; +
-  cout << setprecision(6) << 123.456 << endl; +
-  cout << setprecision(7) << 123.456 << endl; +
-   +
-  cout << showpoint << endl;+
   cout << 30 << " " <<  1000L << " " << 1000.00 << " " << 3.14159;   cout << 30 << " " <<  1000L << " " << 1000.00 << " " << 3.14159;
-  cout << noshowpoint << endl;+  cout << std::noshowpoint << endl;
   cout << 30 << " " << 1000L << " " << 1000.00 << " " << 3.14159;   cout << 30 << " " << 1000L << " " << 1000.00 << " " << 3.14159;
 +  cout << endl;
 +  
 +  cout << std::fixed << endl;
 +  cout << std::setprecision(1) << 123.456 << endl;
 +  cout << std::setprecision(2) << 123.456 << endl;
 +  cout << std::setprecision(3) << 123.456 << endl;
 +  cout << std::setprecision(4) << 123.456 << endl;
 +  cout << std::setprecision(5) << 123.456 << endl;
 +  cout << std::setprecision(6) << 123.456 << endl;
 +  cout << std::setprecision(7) << 123.456 << endl;
 +  
 +  cout << std::scientific << endl;
 +  cout << std::setprecision(1) << 123.456 << endl;
 +  cout << std::setprecision(2) << 123.456 << endl;
 +  cout << std::setprecision(3) << 123.456 << endl;
 +  cout << std::setprecision(4) << 123.456 << endl;
 +  cout << std::setprecision(5) << 123.456 << endl;
 +  cout << std::setprecision(6) << 123.456 << endl;
 +  cout << std::setprecision(7) << 123.456 << endl;
 +  
      
 } }
Line 189: Line 196:
 Εάν δεν ορίσετε δικές σας παραμέτρους εκτύπωσης, οι αριθμοί κινητής υποδιαστολής εκτυπώνονται ως εξής: Εάν δεν ορίσετε δικές σας παραμέτρους εκτύπωσης, οι αριθμοί κινητής υποδιαστολής εκτυπώνονται ως εξής:
     * Εάν ο αριθμός έχει ακέραιο μέρος μεγαλύτερο απο 7 ψηφία, τότε εκτυπώνεται σε εκθετική μορφή.     * Εάν ο αριθμός έχει ακέραιο μέρος μεγαλύτερο απο 7 ψηφία, τότε εκτυπώνεται σε εκθετική μορφή.
 +    * Εάν ο αριθμός έχει ακέραιο μέρος μηδέν και δεκαδικό μέρος με τέσσερα (4) ή περισσότερα μηδενικά στην αρχή εκτυπώνεται σε εκθετική μορφή.
     * Σε αντίθετη περίπτωση,     * Σε αντίθετη περίπτωση,
       * ο αριθμός των εκτυπωσιμων ψηφίων είναι 7, χωρίς να υπολογίζουμε το πρόσημο, την υποδιαστολή και το 0 εάν η απόλυτη τιμή του αριθμού είναι μικρότερη του 1.       * ο αριθμός των εκτυπωσιμων ψηφίων είναι 7, χωρίς να υπολογίζουμε το πρόσημο, την υποδιαστολή και το 0 εάν η απόλυτη τιμή του αριθμού είναι μικρότερη του 1.
       * Εάν το δεκαδικό μέρος του αριθμού είναι μεγαλύτερο από όσο μπορεί να εκτυπωθεί από την παραπάνω σύμβαση, τότε αυτό αποκόπτεται μετά από στρογγυλοποίηση.       * Εάν το δεκαδικό μέρος του αριθμού είναι μεγαλύτερο από όσο μπορεί να εκτυπωθεί από την παραπάνω σύμβαση, τότε αυτό αποκόπτεται μετά από στρογγυλοποίηση.
 </WRAP> </WRAP>
cpp/osteams.txt · Last modified: 2020/05/17 18:10 (external edit)