O
O
Onotolius2022-04-06 23:34:17
C++ / C#
Onotolius, 2022-04-06 23:34:17

Why does division result in zero in C#?

Hello, in the lines below, for some reason, the expression returns zero, it should be 0.0118

Console.WriteLine(Convert.ToInt64("11800000000000000") / Convert.ToInt64(1000000000000000000)); // 0
Console.WriteLine(Convert.ToUInt64("11800000000000000") / Convert.ToUInt64(1000000000000000000)); // 0
Console.WriteLine(Convert.ToInt64("11800000000000000") / 1000000000000000000); // 0
Console.WriteLine(Convert.ToUInt64("11800000000000000") / 1000000000000000000);  // 0

ToInt32 cannot be used, the numbers are large.
Who knows what's the matter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir T, 2022-04-06
@Login8

The division of integers results in an integer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question