+ 1
Why this code gives 153 is Armstrong when run in vs code and gives correct output when run in Sololearn
Why this code gives 153 is Armstrong when run in vs code and gives correct output when run in Sololearn? https://sololearn.com/compiler-playground/cq4XoOXk9HlB/?ref=app
7 Answers
0
153 is Armstrong number, as well as 371. for me gives a correct output
0
Mihaly Nyilas in vs code this code not give correct output
0
did you doublecheck the code in vscode? There might be a typographical error.
you probably made an error is the "is" and "is not" message...
or maybe did not copy the
originalNum = num;
0
Bob_Li actually I asked chat gpt it says amstrong number convert into float because of pow function then I removed pow and used multiplying 3 times then code excited properly you try with you own vs code same code of me please and tell me
0
I guess it depends on your machine and compliler.
It didn't give me the wrong answer when I tried it on my laptop.
But yes, pow could give you sneaky bugs because of it's implementation.
I never realized that.
https://stackoverflow.com/questions/59724493/why-cant-i-reproduce-floating-point-issues-with-pow-function
https://stackoverflow.com/questions/26860574/pow-implementation-in-cmath-and-efficient-replacement
0
Bob_Li am using mingw c++ I don't know but 153 it gives me it's not amstrong when I use pow gpt say it happens because change datatype
0
I made a little modification of the code, so it outputs armstrong numbers up to 10000.........
https://sololearn.com/compiler-playground/cy7emWL57h3z/?ref=app