C
C#13mo ago
Ewan

❔ ✅ How do i divide to 2dp?

How do i divide to 2dp?
No description
16 Replies
Ewan
EwanOP13mo 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
Jimmacle13mo ago
you're doing integer division, which has no fraction
Ewan
EwanOP13mo ago
how do i do it to 2dp? oh?
Jimmacle
Jimmacle13mo ago
you need to change one of the innermost numbers to a floating point number e.g. 35.0 or 35f
Ewan
EwanOP13mo ago
oh i need the decimal?
Jimmacle
Jimmacle13mo ago
at least one of the number literals has to be a floating point type
Ewan
EwanOP13mo 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
Jimmacle13mo ago
you can't do math to only 2 decimal places, but you can change how the string is formatted $"{dpmpercent:F2}"
Ewan
EwanOP13mo ago
can i round it to 2dp somehow? what does the F2 mean?
Jimmacle
Jimmacle13mo ago
it means display it as a fixed point number with 2 decimal places
Ewan
EwanOP13mo ago
oooo i see
Jimmacle
Jimmacle13mo 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
EwanOP13mo ago
youre a god, it works! ill have a look at this, thank you!! <:m_002_love:892466750199848971>
Jimmacle
Jimmacle13mo ago
pepeok
Ewan
EwanOP13mo ago
!close
Accord
Accord13mo 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