Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a better example I posted

https://news.ycombinator.com/item?id=34811353



I haven't tried Bing but ask ChatGPT "what is 12348120348102341 + 10823401828482?"

Bonus points: If you ask Google Search this, it knows the right answer.


Now try this with Google:

“Write an AppleSoft Basic program to do the computation”

(Here it gives me a simplistic Basic program that wouldn’t work because the number would be too large)

Me: “AppleSoft Basic can’t handle numbers that long”

ChatGPT:

You're correct that the integer arithmetic in AppleSoft BASIC has some limitations and cannot handle numbers as large as the sum of the two numbers you provided. AppleSoft BASIC is a 16-bit programming language, which means that it can handle integer values from -32,768 to 32,767.

If you want to work with very large numbers in AppleSoft BASIC, you can use a string to store the numbers and write your own code to perform arithmetic operations on the strings. Here's an example program that demonstrates this approach:

10 A$ = "12348120348102341"

20 B$ = "10823401828482"

30 L = LEN(A$)

40 M = LEN(B$)

50 IF L < M THEN A$ = LEFT$("0", M - L) + A$ : L = M

60 IF M < L THEN B$ = LEFT$("0", L - M) + B$ : M = L

70 C$ = ""

80 R = 0

90 FOR I = L TO 1 STEP -1

100 D = ASC(MID$(A$, I, 1)) + ASC(MID$(B$, I, 1)) - 96 + R

110 C$ = CHR$(D MOD 10 + 48) + C$

120 R = INT(D / 10)

130 NEXT I

140 IF R > 0 THEN C$ = CHR$(R + 48) + C$

150 PRINT C$


Now going back to the original premise, despite this code being wrong, as ChatGPT almost invariably does, do you think it understands the concepts here or is just statistically generating tokens based on previous input?

Really for code generation ChatGPT is an incremental step over StackOverflow. It can kind of nicely template the things you tell it into the code, for the most part, but the code is almost always fundamentally wrong or just mashed together in some way.


I’ve used it generate about 10 scripts that did some combination of json/yaml data wrangling and AWS automation using the AWS SDK in Python. It’s been correct around 90%+ of the time.

Criticizing ChatGPT for getting one line wrong that a human who hasn’t programmed in the same language in over 30 years would also get wrong (I happened to remember the technique from reading it in the back of a magazine in the 80s) and then being able to use it to iterate is like criticizing a monkey who song the national anthem because one note was off key?

How is mashing code together any different than the average human does?


I have also asked it to generated AWS related code in Python and it has something wrong every single time.

Its incrementally better than just copy & pasting from StackOverflow, since it will customize the code for you, but if you try to go beyond what can easily be found on StackOverflow it will fail you.


The AppleSoft BASIC program Bing generated for you won't actually run. Lines 50 and 60 are clearly intended to left-pad the string numbers with leading zeros so they're the same length, but as written they can only add at most one leading zero, so B$ will not be padded correctly and the calculation will fail.


BTW: click on “X minutes ago” in the comment to reply when you don’t see a reply link.

I asked it to “explain every line of code”. I had to copy and paste the original code back into a new session.

Yes I know, they comments should have been separated by a “:REM”. But that wouldn’t work either on a real Apple //. Lines can’t be longer than 256 characters

That is one issue I have with ChatGPT. It is only helpful as a shortcut for coding based on a domain you already know - not something I haven’t coded in since 1992.

I could have immediately caught errors with generated Python/boto3 (AWS SDK). I use that everyday and I could have tested it.

me: “left$ doesn’t do padding, it returns the first characters of a string”

ChatGPT: (Gave me another sample with the String() function)

Me: That function isn’t available in AppleSoft Basic

ChatGPT: (Gave me something with the syntax of “0” * n to pad)

Me: that syntax doesn’t work in AppleSoft basic

ChatGPT:

10 A$ = "12348120348102341" ' Initialize first number

20 B$ = "10823401828482" ' Initialize second number

30 L = LEN(A$) ' Determine length of first number

40 M = LEN(B$) ' Determine length of second number

50 IF L < M THEN FOR I = 1 TO M - L : A$ = "0" + A$ : NEXT I : L = M ' Pad first number with zeros if it is shorter than second number

60 IF M < L THEN FOR I = 1 TO L - M : B$ = "0" + B$ : NEXT I : M = L ' Pad second number with zeros if it is shorter than first number

70 C$ = "" ' Initialize result string

80 R = 0 ' Initialize carry variable to 0

90 FOR I = L TO 1 STEP -1 ' Loop through the digits of the numbers, starting from the rightmost digit

100 D = ASC(MID$(A$, I, 1)) + ASC(MID$(B$, I, 1)) - 96 + R ' Add the two digits, subtract 96 to convert from ASCII to digit value, and add any carry from the previous digit

110 C$ = CHR$(D MOD 10 + 48) + C$ ' Compute the digit value of the sum and append it to the result string

120 R = INT(D / 10) ' Determine the carry for the next digit 130 NEXT I ' Move on to the next digit

(I left off the last two lines they are the same as before. It was a bad copy paste error)


You linked to your parent comment?


My bad, I had two examples going on at once. I thought this thread was to the simpler one.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: