❔ c# vs code help needed

i made a perfect running script but when i get to high numbers vs code freezes
29 Replies
PotatoHunter
PotatoHunterOP2y ago
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???)
Angius
Angius2y ago
Well, different numeric types have different maximum values
MODiX
MODiX2y ago
Angius#1586
REPL Result: Success
(Int: int.MaxValue, Long: long.MaxValue)
(Int: int.MaxValue, Long: long.MaxValue)
Result: ValueTuple<int, long>
{
"item1": 2147483647,
"item2": 9223372036854775807
}
{
"item1": 2147483647,
"item2": 9223372036854775807
}
Compile: 358.767ms | Execution: 50.318ms | React with ❌ to remove this embed.
Angius
Angius2y ago
Those values for an int and a long, for example
Thinker
Thinker2y ago
Just to clarify, did you literally type out 2 ^ 31 in code, or do you just mean "2 to the power of 31"
PotatoHunter
PotatoHunterOP2y ago
power of 31 you cant do 2 ^ 31 in c# its Math.Pov(2,31)
Thinker
Thinker2y ago
yeah, was just making sure
PotatoHunter
PotatoHunterOP2y ago
which took me a while to realize lol
Thinker
Thinker2y ago
to be clear, the biggest possible value of an int is 2 ^ 32 - 1
PotatoHunter
PotatoHunterOP2y ago
hmm
Thinker
Thinker2y ago
although I don't think it should crash when it overflows, rather it should just... overflow
PotatoHunter
PotatoHunterOP2y ago
yup thats a mersenne prime yeah it dont crash it just freezes there
Thinker
Thinker2y ago
"freezes" in what sense? does it freeze VS Code? does it freeze some loop?
PotatoHunter
PotatoHunterOP2y ago
i cant write anything in terminal
Thinker
Thinker2y ago
Show your code
PotatoHunter
PotatoHunterOP2y ago
ok what was the website for code copy paste thing
Thinker
Thinker2y ago
$paste
MODiX
MODiX2y ago
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!
PotatoHunter
PotatoHunterOP2y ago
BlazeBin - ohazcrbylovz
A tool for sharing your source code with the world!
PotatoHunter
PotatoHunterOP2y ago
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
Thinker
Thinker2y ago
btw m > 9 || m == 9 can be shortened to m >= 9
PotatoHunter
PotatoHunterOP2y ago
oh thanks *when i change it to smth lower than 9 it works
Thinker
Thinker2y ago
Looks like m being greater than or equal to 9 should result in the program exiting
PotatoHunter
PotatoHunterOP2y ago
yep 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?
Thinker
Thinker2y ago
Try debugging your code i.e. using the debugger to step through your code
PotatoHunter
PotatoHunterOP2y ago
sorry im new to this wheres the debugger (also my english kinda bad)
PotatoHunter
PotatoHunterOP2y ago
ahh im going to try this later i dont have much time rn
Accord
Accord2y ago
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