PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are developing an application that includes methods named ConvertAmount and TransferFunds.
You need to ensure that the precision and range of the value in the amount variable is not lost when
the TransferFunds() method is called.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
The double keyword signifies a simple type that stores 64-bit floating-point values.
The float keyword signifies a simple type that stores 32-bit floating-point values.

double (C# Reference)

3 Comments on “Which code segment should you use?

    1. zerocool says:

      Tested the code with float amount = 123.123456789F; This resulted in:

      A funds = 123,123458862305
      B funds = 123,1235
      D funds = 123

      7 digits must be conserved by the conversion.
      Looks like there is some rounding going on at the decimal conversion, and its only correct in 6 digits.




      0



      0

Leave a Reply