credit-card-validator icon indicating copy to clipboard operation
credit-card-validator copied to clipboard

qurey raised in the code

Open nainshree-raj opened this issue 2 years ago • 3 comments

Hello! i have a query in your code why are you taking the difference of 'ccNumber[i] with 48' in the code?

nainshree-raj avatar Apr 13 '22 17:04 nainshree-raj

In the code, the character being validated subtracts 48 due to it being a character and not an integer. The ASCII value for each integer character is 48 plus the integer itself. i.e. 48 + 0 = 48, therefore 0 in ASCII is 48. Therefore, the intrinsic cast is casting to the number plus 48. Should have been a comment explaining that in the code.

SpencerBrown1452 avatar May 13 '22 07:05 SpencerBrown1452

I feel this issue should be marked as resolved and closed.

nic-obert avatar Aug 13 '23 09:08 nic-obert

48 is the ascii value of char '0' for more reference visit chat gpt

Bish18 avatar Sep 04 '23 06:09 Bish18