Could anyone please explain me the operation of ada.unchecked_coversion(float, UnsignedInteger). What this operation will be performed ? Could anyone please clarify this with example. Thanks a lot in advance.
Could anyone please explain me the operation of ada.unchecked_coversion(float, UnsignedInteger). What this operation will be performed ? Could anyone please clarify this with example. Thanks a lot in advance.
From here
An unchecked conversion is a bit-for-bit copy without regard to the meanings attached to those bits and bit positions by either the source or the destination type. The source bit pattern can easily be meaningless in the context of the destination type. Unchecked conversions can create values that violate type constraints on subsequent operations. Unchecked conversion of objects mismatched in size has implementation-dependent results.
So it should be used with care and only for types that have "same" bit representation. e.g it wouldn't probably work to cast float to int as those types could be represented differently in memory.
Here are two variables
before conversion
and after calling unchecked conversion
As you can see whole operation is just bit by bit copy of source variable to target variable
Hope this answers your questions