You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rounds a floating-point value to the nearest integer.
15
+
Rounds a floating-point value to the nearest integer value.
16
16
17
17
## Syntax
18
18
@@ -68,46 +68,60 @@ For additional compatibility information, see [Compatibility](../../c-runtime-li
68
68
## Example
69
69
70
70
```C
71
-
// crt_round.c
72
-
// Build with: cl /W3 /Tc crt_round.c
73
-
// This example displays the rounded results of
74
-
// the floating-point values 2.499999, -2.499999,
75
-
// 2.8, -2.8, 2.5 and -2.5.
71
+
// Build with: cl /W3 /Tc
72
+
// This example displays the rounded
73
+
// results of floating-point values
76
74
77
75
#include <math.h>
78
76
#include <stdio.h>
79
77
80
-
int main( void )
78
+
int main()
81
79
{
82
-
double x = 2.499999;
83
-
float y = 2.8f;
84
-
long double z = 2.5;
85
-
86
-
printf("round(%f) is %.0f\n", x, round(x));
87
-
printf("round(%f) is %.0f\n", -x, round(-x));
88
-
printf("roundf(%f) is %.0f\n", y, roundf(y));
89
-
printf("roundf(%f) is %.0f\n", -y, roundf(-y));
90
-
printf("roundl(%Lf) is %.0Lf\n", z, roundl(z));
91
-
printf("roundl(%Lf) is %.0Lf\n", -z, roundl(-z));
80
+
printf("===== Round a float\n\n");
81
+
float floatValue = 2.4999999f; // float stores a value close to, but not exactly equal to, the initializer below. floatValue will contain 2.5 because it is the closest single precision value
82
+
printf("roundf(%.1000g) is %.1000g\n", floatValue, roundf(floatValue));
83
+
printf("roundf(%.1000g) is %.1000g\n", -floatValue, roundf(-floatValue));
84
+
85
+
// double stores a value close to, but not exactly equal to, the initializer below. The closest double value is just slightly larger.
86
+
double doubleValue = 2.4999999;
87
+
printf("\n===== Round a double\n\n");
88
+
printf("round(%.1000g) is %.1000g\n", doubleValue, round(doubleValue));
89
+
printf("round(%.1000g) is %.1000g\n", -doubleValue, round(-doubleValue));
90
+
91
+
// long double stores a value close to, but not exactly equal to, the initializer below. The closest long double value is just slightly larger.
92
+
long double longDoubleValue = 2.4999999L;
93
+
printf("\n===== Round a long double\n\n");
94
+
printf("roundl(%.1000g) is %.1000g\n", longDoubleValue, roundl(longDoubleValue));
95
+
printf("roundl(%.1000g) is %.1000g\n", -longDoubleValue, roundl(-longDoubleValue));
96
+
97
+
return 0;
92
98
}
93
99
```
94
100
95
101
```Output
96
-
round(2.499999) is 2
97
-
round(-2.499999) is -2
98
-
roundf(2.800000) is 3
99
-
roundf(-2.800000) is -3
100
-
roundl(2.500000) is 3
101
-
roundl(-2.500000) is -3
102
+
===== Round a float
103
+
104
+
roundf(2.5) is 3
105
+
roundf(-2.5) is -3
106
+
107
+
===== Round a double
108
+
109
+
round(2.499999900000000163657887242152355611324310302734375) is 2
110
+
round(-2.499999900000000163657887242152355611324310302734375) is -2
111
+
112
+
===== Round a long double
113
+
114
+
roundl(2.499999900000000163657887242152355611324310302734375) is 2
115
+
roundl(-2.499999900000000163657887242152355611324310302734375) is -2
@@ -88,6 +92,8 @@ Zero if successful, an error code on failure.
88
92
89
93
## Remarks
90
94
95
+
The **strerror_s** function is thread-safe.
96
+
91
97
The **strerror_s** function maps *errnum* to an error-message string, returning the string in *buffer*. **_strerror_s** doesn't take the error number; it uses the current value of **errno** to determine the appropriate message. Neither **strerror_s** nor **_strerror_s** actually prints the message: For that, you need to call an output function such as [fprintf](fprintf-fprintf-l-fwprintf-fwprintf-l.md):
92
98
93
99
```C
@@ -137,7 +143,7 @@ See the example for [perror](perror-wperror.md).
Copy file name to clipboardExpand all lines: docs/linux/cmake-linux-configure.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ When you do a build:
96
96
97
97
## Choose a Linux target
98
98
99
-
When you open a CMake project folder, Visual Studio parses the *CMakeLists.txt* file and specifies a Windows target of **x86-Debug**. To target a remote Linux system, you'll change the project settings to**Linux-Debug** or **Linux-Release**.
99
+
When you open a CMake project folder, Visual Studio parses the *CMakeLists.txt* file and specifies a Windows target of **x86-Debug**. To target a remote Linux system, you'll change the project settings, based on your Linux compiler, to something like**Linux-Debug** or **Linux-Release**.
100
100
101
101
If you specify a remote Linux target, your source is copied to the remote system.
Copy file name to clipboardExpand all lines: docs/linux/linux-asan-configuration.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Configure Linux projects to use Address Sanitizer"
3
3
description: "Describes how to configure C++ Linux projects in Visual Studio to use Address Sanitizer."
4
-
ms.date: "06/07/2019"
4
+
ms.date: "09/25/2020"
5
5
---
6
6
# Configure Linux projects to use Address Sanitizer
7
7
@@ -27,7 +27,7 @@ You can also view the full ASan output (including where the corrupted memory was
27
27
## Enable ASan for MSBuild-based Linux projects
28
28
29
29
> [!NOTE]
30
-
> Starting in Visual Studio 2019 version 16.4, AddressSanitizer for Linux projects is enabled via **Configuration Properties** > **C/C++** > **Enable Address Sanitizer**.
30
+
> Starting in Visual Studio 2019 version 16.4, AddressSanitizer for Linux projects is enabled via **Project properties** > **Configuration Properties** > **C/C++** > **Enable Address Sanitizer**.
31
31
32
32
To enable ASan for MSBuild-based Linux projects, right-click on the project in **Solution Explorer** and select **Properties**. Next, navigate to **Configuration Properties** > **C/C++** > **Sanitizers**. ASan is enabled via compiler and linker flags, and requires your project to be recompiled to work.
33
33
@@ -45,7 +45,7 @@ Make sure you have a Linux configuration (for example, **Linux-Debug**) selected
45
45
46
46

47
47
48
-
The ASan options are under **General**. Enter the ASan runtime flags in the format "flag=value", separated by semicolons.
48
+
The ASan options are under **General**. Enter the ASan runtime flags in the format "flag=value", separated by spaces. The UI incorrectly suggests using semi-colons. Use spaces or colons, instead.
49
49
50
50

During message handling, checking a class's own message map is not the end of the message-map story. What happens if class `CMyView` (derived from `CView`) has no matching entry for a message
10
+
During message handling, checking a class's own message map is not the end of the message-map story. What happens if class `CMyView` (derived from `CView`) has no matching entry for a message?
10
11
11
-
Keep in mind that `CView`, the base class of `CMyView`, is derived in turn from `CWnd`. Thus `CMyView`*is* a `CView` and *is* a `CWnd`. Each of those classes has its own message map. The figure "A View Hierarchy" below shows the hierarchical relationship of the classes, but keep in mind that a `CMyView` object is a single object that has the characteristics of all three classes.
12
+
Keep in mind that `CView`, the base class of `CMyView`, is derived in turn from `CWnd`. Thus `CMyView`*is* a `CView` and *is* a `CWnd`. Each of those classes has its own message map. The figure below shows the hierarchical relationship of the classes, but keep in mind that a `CMyView` object is a single object that has the characteristics of all three classes.
12
13
13
14
 <br/>
14
15
A View Hierarchy
15
16
16
-
So if a message can't be matched in class `CMyView`'s message map, the framework also searches the message map of its immediate base class. The `BEGIN_MESSAGE_MAP` macro at the start of the message map specifies two class names as its arguments:
17
+
If a message can't be matched in class `CMyView`'s message map, the framework also searches the message map of its immediate base class. The `BEGIN_MESSAGE_MAP` macro at the start of the message map specifies two class names as its arguments:
The first argument names the class to which the message map belongs. The second argument provides a connection with the immediate base class — `CView` here — so the framework can search its message map, too.
21
+
The first argument names the class to which the message map belongs. The second argument provides a connection with the immediate base class, in this case `CView`, so that the framework can search its message map, too.
21
22
22
23
The message handlers provided in a base class are thus inherited by the derived class. This is very similar to normal virtual member functions without needing to make all handler member functions virtual.
0 commit comments