found a small bug when there's a 0 in the thousands, millions, etc position
Closed this issue · 3 comments
inside the WHILE @Number > 0
loop, you might want to rework the following lines as indicated below, because it's not clearing the contents of the @vSubResult variable each time thru the loop. Therefore, when the SELECT @vSubResult = Nam FROM @tDict WHERE Num = @v0Num
doesn't find a result, because @v0Num is 0, the @vSubResult variable retains its previous value.
Current Code:
IF @v000Num = 0
BEGIN
SET @vSubResult = ''
END
ELSE
BEGIN
Proposed Code:
SET @vSubResult = ''; --start out blank each time thru the loop to avoid remnants from previous iteration
IF @v000Num > 0
BEGIN
When i made this change on my side, it works perfectly!
Example of issue:
Using Current Code:
20200 -> 'twenty-two hundred thousand two hundred'
Using Proposed Code:
20200 -> 'twenty- thousand two hundred'
(I have another "fix" suggestion for the dangling dash, shown above, which i also discovered while testing on this and other values, but i can submit that as a separate gh issue)
i suppose i can try these as pull requests and submit the fixes myself.. i'm just not that familiar with pull requests. been using git/github for years for our own private projects, but never had the need to do PR's on public projects.. this seems like as good a time as any to start, right? esp since it's a rather simple fix..
not sure if i did the pull request correctly, but i forked the project first, made my change in my forked repo, then created the pull request, comparing my latest "master" branch to yours. in my commit, i also included a new test case in the comments at the bottom of the sql, and then replaced the test image with the results that now includes the additional test case. if you approve/agree with this enhancement, i wouldn't mind applying the same fix to all the other language scripts, too, if you want.. up to you.
that said, i just noticed some of the other languages already have this "fix" in place. for example, the following languages seem to have a similar fix in place: CZ, DK, FI, HE, HI, KZ, LT, LV, NO, RU, SL, SR, TE, TH, TR, UK.
so i guess most of them have the "fix" already, but since I use the EN one, that's the one I noticed first. and now that i'm looking at all the other languages, perhaps i should not try to update any of the others, since i don't really know all the rules of the other languages, and I'd be afraid to mess something else up. heh. in any event, i'll go ahead and create another issue re: the dangling dash, and that's all i got for now. aside from these small bugs i came across, the function is great and VERY helpful. thank you so much for putting this together.