diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/crt32/iostream/ostrdbl.cxx | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/crt32/iostream/ostrdbl.cxx')
-rw-r--r-- | private/crt32/iostream/ostrdbl.cxx | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/private/crt32/iostream/ostrdbl.cxx b/private/crt32/iostream/ostrdbl.cxx new file mode 100644 index 000000000..1d8f22060 --- /dev/null +++ b/private/crt32/iostream/ostrdbl.cxx @@ -0,0 +1,65 @@ +/*** +* ostrdbl.cxx - definitions for ostream class operator<<(double) functions +* +* Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved. +* +*Purpose: +* Contains the member function definitions for ostream operator<<(double). +* +*Revision History: +* 09-23-91 KRS Created. Split out from ostream.cxx for granularity. +* 10-24-91 KRS Combine float version with double. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <internal.h> +#include <stdlib.h> +#include <stdio.h> +#include <float.h> +#include <iostream.h> +#pragma hdrstop + +#pragma check_stack(on) // large buffer(s) + +ostream& ostream::operator<<(double f) +{ +_WINSTATIC char obuffer[24]; +_WINSTATIC char fmt[8]; +_WINSTATIC char leader[4]; + char * optr = obuffer; + int x = 0; + + // x_floatused nonzero indicates called for float, not double + unsigned int curprecision = (x_floatused) ? FLT_DIG : DBL_DIG; + x_floatused = 0; // reset for next call + + curprecision = __min((unsigned)x_precision,curprecision); + + if (opfx()) { + if (x_flags & ios::showpos) + leader[x++] = '+'; + if (x_flags & ios::showpoint) + leader[x++] = '#'; // show decimal and trailing zeros + leader[x] = '\0'; + x = sprintf(fmt,"%%%s.%.0ug",leader,curprecision) - 1; + if ((x_flags & ios::floatfield)==ios::fixed) + fmt[x] = 'f'; + else + { + if ((x_flags & ios::floatfield)==ios::scientific) + fmt[x] = 'e'; + if (x_flags & uppercase) + fmt[x] = (char)toupper(fmt[x]); + } + + sprintf(optr,fmt,f); + x = 0; + if (*optr=='+' || *optr=='-') + leader[x++] = *(optr++); + leader[x] = '\0'; + writepad(leader,optr); + osfx(); + } + return *this; +} |