exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 2 question 124 discussion

Actual exam question from Microsoft's 70-483
Question #: 124
Topic #: 2
[All 70-483 Questions]

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?

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
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.
Reference: double (C# Reference)

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
supersunny
Highly Voted 5 years, 10 months ago
A is good for the requirement.
upvoted 11 times
ptarasov
5 years, 4 months ago
Why not B?
upvoted 4 times
...
...
rhysabray
Highly Voted 5 years, 3 months ago
It seems both A and B are correct, but if I had to pick then I choose B. A - Converts float(4 bytes) to double(8 bytes) and keeps the double B - Converts float(4 bytes) to decimal(12 bytes) and keeps the decimal Because both are being converted to something more precise and do not undergo further conversions then both are suitable. However, decimal needs 12 bytes of memory and millions of stored values in this form would certainly be larger than storing the same number of doubles. Despite this, Decimals do not employ the same ability to lose or round digits through conversion unlike their binary counterparts and as the question explicitly asks to ensure that "precision and range is not lost". Within finance, use decimals, people don't like losing money through rounding errors.. so B! Anywhere else, A would be the best - less memory and usually tiny rounding errors wont matter.
upvoted 7 times
Ragou
5 years ago
the requirement are to keep precision and range of the float. Only the double is suitable for both: https://stackoverflow.com/questions/618535/difference-between-decimal-float-and-double-in-net float: ±1.5 x 10^-45 to ±3.4 x 10^38 (~7 significant figures) double: ±5.0 x 10^-324 to ±1.7 x 10^308 (15-16 significant figures) decimal: ±1.0 x 10^-28 to ±7.9 x 10^28 (28-29 significant figures)
upvoted 6 times
...
...
HgstExam
Most Recent 4 years, 9 months ago
A is the right anwser, while decimal is more precise, double is needed to keep the RANGE
upvoted 4 times
...
GeorgeMg
4 years, 10 months ago
decimal is fine for the precision but not always enough for the range. for example if the value is 1e35 decimal would not take it. So, go for the A.
upvoted 4 times
...
CNTPD1
4 years, 11 months ago
Question states that prescision AND range needs to be kept. decimal is way to go, see fiddle https://dotnetfiddle.net/YDksxb
upvoted 1 times
CNTPD1
4 years, 11 months ago
I mean B is better suited to be an answer, but A works too.
upvoted 2 times
...
...
Andrei
5 years, 9 months ago
I guess is B :)
upvoted 6 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...