❔ c# vs code help needed
i made a perfect running script but when i get to high numbers vs code freezes
29 Replies
when a variable gets to smth like 2 ^ 31 it freezes
maybe even less
is there any way i can maximize the digit limit of a variable(if theres something like that???)
Well, different numeric types have different maximum values
Angius#1586
REPL Result: Success
Result: ValueTuple<int, long>
Compile: 358.767ms | Execution: 50.318ms | React with ❌ to remove this embed.
Those values for an
int
and a long
, for exampleJust to clarify, did you literally type out
2 ^ 31
in code, or do you just mean "2 to the power of 31"power of 31
you cant do 2 ^ 31 in c#
its Math.Pov(2,31)
yeah, was just making sure
which took me a while to realize lol
to be clear, the biggest possible value of an
int
is 2 ^ 32 - 1hmm
although I don't think it should crash when it overflows, rather it should just... overflow
yup thats a mersenne prime
yeah it dont crash
it just freezes there
"freezes" in what sense?
does it freeze VS Code? does it freeze some loop?
i cant write anything in terminal
Show your code
ok
what was the website for code copy paste thing
$paste
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
BlazeBin - ohazcrbylovz
A tool for sharing your source code with the world!
when i change the -magic- number 9 in the line 31 and 38 it works
it finishes the code
but when its 9 it keeps looking for it but since it cant find it the script never ends so the vs just freezes
btw
m > 9 || m == 9
can be shortened to m >= 9
oh thanks
*when i change it to smth lower than 9 it works
Looks like
m
being greater than or equal to 9 should result in the program exitingyep but it freezes when it hits the 8
oh
wait
uh
yeah
it freezes when it hits 8
hmm i think i understand
line
34
it hits higher than 2 ^ 31 - 1
1 single number higher
which leds the program to crash?
Try debugging your code
i.e. using the debugger to step through your code
sorry im new to this
wheres the debugger
(also my english kinda bad)
Debug a .NET console application using Visual Studio Code - .NET
Learn how to debug a .NET console app using Visual Studio Code.
ahh im going to try this later i dont have much time rn
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.