C
C#8mo ago
Ewan

❔ ✅ How do i divide to 2dp?

How do i divide to 2dp?
No description
16 Replies
Ewan
Ewan8mo ago
using this code, the answer i get is 0 when i change the 18/35 to 35/35 it writes 100 which is correct
Jimmacle
Jimmacle8mo ago
you're doing integer division, which has no fraction
Ewan
Ewan8mo ago
how do i do it to 2dp? oh?
Jimmacle
Jimmacle8mo ago
you need to change one of the innermost numbers to a floating point number e.g. 35.0 or 35f
Ewan
Ewan8mo ago
oh i need the decimal?
Jimmacle
Jimmacle8mo ago
at least one of the number literals has to be a floating point type
Ewan
Ewan8mo ago
ooo ok that works! but now how do i do it to 2dp only? i dont want a long list of numbers, i just want it to 2dp
Jimmacle
Jimmacle8mo ago
you can't do math to only 2 decimal places, but you can change how the string is formatted $"{dpmpercent:F2}"
Ewan
Ewan8mo ago
can i round it to 2dp somehow? what does the F2 mean?
Jimmacle
Jimmacle8mo ago
it means display it as a fixed point number with 2 decimal places
Ewan
Ewan8mo ago
oooo i see
Jimmacle
Jimmacle8mo ago
Standard numeric format strings - .NET
In this article, learn to use standard numeric format strings to format common numeric types into text representations in .NET.
Ewan
Ewan8mo ago
youre a god, it works! ill have a look at this, thank you!! <:m_002_love:892466750199848971>
Jimmacle
Jimmacle8mo ago
pepeok
Ewan
Ewan8mo ago
!close
Accord
Accord8mo ago
Closed! Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts