Relative Content

Tag Archive for c++math

how d i fix this number of digits counter in C lang code?

#include <stdio.h> int digits (int n); int main () { int c,d; while((c = scanf(“%d”,&d))!=EOF) { printf(“%d n”,digits(d)); } return 0 ; } int digits (int n) { int p ; if (n<10) { p++ ; return p; } else { p++; n/=10; digits (n); } } i expected it to recursively increase p but […]

C# Math.Round() result is unpredictable

I have encountered this issue in my .NET Framework 4.8 project, but it also can be reproduced in .NET 8 (https://learn.microsoft.com/en-us/dotnet/api/system.math.round?view=net-8.0#code-try-2).