Author Topic: possible bug  (Read 3355 times)

0 Members and 1 Guest are viewing this topic.

Offline random1

  • Newbie
  • Posts: 86
    • View Profile
possible bug
« on: October 22, 2019, 08:12:41 pm »
SDL calculates correctly but not GL
Simple code to count total digits by value in a string.  Counts for zero's is incorrect. 

Code: QB64: [Select]
  1. HOLD$ = "52359877559829887307710723054658"
  2.  
  3. FOR X = 1 TO LEN(HOLD$)
  4.     A$ = MID$(HOLD$, X, 1)
  5.     IF A$ = "0" THEN H0 = H0 + 1
  6.     IF A$ = "1" THEN H1 = H1 + 1
  7.     IF A$ = "2" THEN H2 = H2 + 1
  8.     IF A$ = "3" THEN H3 = H3 + 1
  9.     IF A$ = "4" THEN H4 = H4 + 1
  10.     IF A$ = "5" THEN H5 = H5 + 1
  11.     IF A$ = "6" THEN H6 = H6 + 1
  12.     IF A$ = "7" THEN H7 = H7 + 1
  13.     IF A$ = "8" THEN H8 = H8 + 1
  14.     IF A$ = "9" THEN H9 = H9 + 1
  15.  

Offline random1

  • Newbie
  • Posts: 86
    • View Profile
Re: possible bug
« Reply #1 on: October 22, 2019, 08:34:44 pm »
Never mind, restarted computer after windows update and now working correctly.
R1

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: possible bug
« Reply #2 on: October 22, 2019, 09:15:15 pm »
Yeah works pretty good:
Code: QB64: [Select]
  1. 'RANDOMIZE TIMER
  2. 'FOR i = 0 TO 9
  3. '    hold$ = hold$ + STRING$(9 - i, _TRIM$(STR$(i)))
  4. 'NEXT
  5. 'FOR i = LEN(hold$) TO 1 STEP -1
  6. '    r = INT(RND * (i + 1))
  7. '    t$ = MID$(hold$, i, 1)
  8. '    MID$(hold$, i, 1) = MID$(hold$, r, 1)
  9. '    MID$(hold$, r, 1) = t$
  10. 'NEXT
  11. '_CLIPBOARD$ = hold$
  12.  
  13. hold$ = "213048303442240111021672006450613201255301753"
  14. PRINT "hold$ = "; hold$
  15. FOR X = 1 TO LEN(hold$)
  16.     h(VAL(MID$(hold$, X, 1))) = h(VAL(MID$(hold$, X, 1))) + 1
  17. FOR i = 0 TO 9
  18.     PRINT "hold$ has"; h(i); _TRIM$(STR$(i)); "'s."
  19.