View previous topic :: View next topic |
Author |
Message |
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Aug 11, 2004 2:55 pm Post subject: Bug in VDS 5? |
|
|
I seem to be having a problem with VDS 5 telling the difference between a (.) and a (0)
Reference:
. = @chr(46)
0 = @chr(48)
Code: | %S = 0. Some sentence here
If @equal(@chr(46),@substr(%S,1))
%S = @strdel(%S,1)
end
Info %S
exit |
result %S = . Some sentence here
Code: | %S = .0 Some sentence here
If @equal(@chr(46),@substr(%S,1))
If @not(@equal(@chr(48),@substr(%S,1)))
%S = @strdel(%S,1)
end
end
Info %S
exit |
result %S = unchanged
The same is true if I use the actual character eg. "." and "0" instead of @chr(46) and @chr(48)
Is this a bug or am I doing something wrong? |
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Aug 11, 2004 4:10 pm Post subject: |
|
|
I think you are trying to make this point?
Code: | if @equal(0,.)
warn Bug!
end |
Indeed, it seems strange that VDS thinks a zero and a decimal are the
same/equal. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Aug 11, 2004 4:56 pm Post subject: |
|
|
That is exactly my point.
Thank you for the simlification FreezingFire |
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Aug 11, 2004 4:59 pm Post subject: |
|
|
Looks like a bug. I'll move this to Bug Reports. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Aug 11, 2004 6:25 pm Post subject: |
|
|
It might not be a bug. I think VDS treats the two arguments as numbers because a dot is the decimalseperator used by VDS: a dot means 0.0 => 0... Look at this example:
Code: | option decimalsep,","
if @equal(0,.)
warn Bug!
else
info Bugfree!?
end |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
Back to top |
|
|
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Wed Aug 11, 2004 6:43 pm Post subject: |
|
|
Of course if using Skit's technique there will be another problem:
Code: | option decimalsep,","
if @equal(0,",")
warn Bug!
else
info Bugfree!?
end |
A solution is, as I think has been discussed before, to include non-numeric characters
in the comparison like this:
Code: | %a = 0
%b = .
if @equal("x"%a"x","x"%b"x")
info Variables are equal.
else
info Variables are unequal.
end |
|
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Aug 11, 2004 11:05 pm Post subject: |
|
|
Tommy wrote: | A solution is, as I think has been discussed before, to include non-numeric characters
in the comparison like this:
Code: | %a = 0
%b = .
if @equal("x"%a"x","x"%b"x")
info Variables are equal.
else
info Variables are unequal.
end |
|
Nice workaround. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Thu Aug 12, 2004 2:19 am Post subject: |
|
|
Thanks for all the help guys. You have saved me from alot of work |
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Thu Aug 12, 2004 2:24 am Post subject: |
|
|
Anyone notice that this wasn't a bug in VDS 4? _________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Thu Aug 12, 2004 11:15 am Post subject: |
|
|
I've mentioned it before, as I too have been caught by it. It isn't a bug, it's just due to the fact that VDS tries a numeric comparison first, and does a text comparison second if either of the values turn out to be non-numeric. For some reason, Borland's numeric evaluation code does not consider "." to be non-numeric, but a value of zero. I guess the same would apply to "," in countries where that is a decimal separator.
VDS 4 used older code, which did not properly take account of the system settings for number formats. The change you note will have been a side-effect of correcting this. _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Thu Aug 12, 2004 6:03 pm Post subject: |
|
|
Hmmmmm...... Bug? Side Effect? Is there really a difference? _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
PGWARE Web Host
Joined: 29 Dec 2001 Posts: 1562
|
Posted: Thu Aug 12, 2004 6:54 pm Post subject: |
|
|
I wouldn't call this a bug, Borland made a change to how they recognize numeric digits, they now consider the decimal pointers as numeric. As that is often used in numerical operations with floating point numbers. |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Fri Aug 13, 2004 8:05 am Post subject: |
|
|
A bug, to me, is the result of a mistake, an error in coding. I don't consider using the native run-time library routines to determine whether a string is numeric or not is an error in coding.
Unfortunately, with something as complex as VDS, it's almost impossible to change or improve something without affecting code that relied on it working in some specific way that was not actually documented. _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Fri Aug 13, 2004 9:10 am Post subject: |
|
|
I don't think the @equal(.,0) thing is a bug, but I do consider the next code as one:
Code: | option decimalsep,.
info This does work: @fadd(.,.)
info So does this: @fadd(0,0)
info And while 0 - 0 does work: @diff(0,0)
# It goes wrong with the next line:
info This doesn't: @diff(.,.) |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Fri Aug 13, 2004 10:02 am Post subject: |
|
|
No it's not, because @diff() is meant to work with integers, which should not have decimal points in them. @fsub(.,.) would probably work, as that is the function you're supposed to use for subtracting floating point numbers. _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
|