Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 1006 Bytes

casting-integers-to-floating-point-values.md

File metadata and controls

18 lines (13 loc) · 1006 Bytes
description title ms.date helpviewer_keywords ms.assetid
Learn more about: Casting Integers to Floating-Point Values
Casting Integers to Floating-Point Values
11/04/2016
integers, casting to floating-point values
81fd5b7d-15eb-4c11-a8c8-e1621ff54fd3

Casting Integers to Floating-Point Values

ANSI 3.2.1.3 The direction of truncation when an integral number is converted to a floating-point number that cannot exactly represent the original value

When an integral number is cast to a floating-point value that cannot exactly represent the value, the value is rounded (up or down) to the nearest suitable value.

For example, casting an unsigned long (with 32 bits of precision) to a float (whose mantissa has 23 bits of precision) rounds the number to the nearest multiple of 256. The long values 4,294,966,913 to 4,294,967,167 are all rounded to the float value 4,294,967,040.

See also

Floating-Point Math