RE: [U2] RE: UniBasic code that should work
OP doesn't say which database, except that UniBasic suggests UniData and on my machine it works fine in Universe but as described in UniData (5.2.3 on RHL)! Wide-zero is a Universe-specific feature so wouldn't affect UniData I'm baffled - adding additional prints to the code suggests that both variables are of equal length consisting of the same characters, that A-B = 0 but that A is greater than B. If you change the assignment of B to B = 4.58 - 4.59 then it works fine, but B = 0 - 0.01 still fails If you step through with the UniBasic debugger everything still appears the same, but this time it works correctly !! Any UniData gurus out there who can suggest an explanation ? Piers -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Kevin King Sent: 29 March 2006 01:53 To: u2-users@listserver.u2ug.org Subject: [U2] RE: UniBasic code that should work Sounds like Universe and the WIDE0 setting again. Seems we've seen a lot of that kind of stuff in the past few months. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, March 28, 2006 5:48 PM To: u2users Subject: UniBasic code that should work Posted on behalf of a colleague who wishes to remain nameless... UniBasic code that should work The results of the following code are proving to be troublesome: A = 4.57 + (-4.58) B = (-0.01) PRINT 'TEST ONE: ARE ':A:' AND ':B:' THE SAME? ': IF A = B THEN PRINT 'YES' END ELSE PRINT 'NO' END A = OCONV(A,'MD20') B = OCONV(B,'MD20') PRINT 'TEST TWO: ARE ':A:' AND ':B:' THE SAME? ': IF A = B THEN PRINT 'YES' END ELSE PRINT 'NO' END You would expect both tests to return 'YES', but in fact, only the second test returns 'YES'. TEST ONE: ARE -0.01 AND -0.01 THE SAME? NO TEST TWO: ARE -0.01 AND -0.01 THE SAME? YES Is there something simple that I am missing? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups u2users group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/u2users -~--~~~~--~~--~--~--- -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.385 / Virus Database: 268.3.2/294 - Release Date: 3/27/2006 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] RE: UniBasic code that should work
In UniData see HELP FLOAT.PRECISION. Here is a website that explains some of the problems with using floating point math: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.h tm. I ran across this a couple years back when a colleague updated an A/R report to not print 0.00 values - but it still did. Informix (at that time) explained it as a feature that you had these options to use to change how the results from mathematical operations were returned. I still haven't wrapped my mind around the fact that every single way you have to look at these values (print, crt, written to a file, viewed in the debugger, len, etc) made them look the same - but they would not return TRUE if tested to be the same. I've always thought that it seemed to be pretty similar to the problem Intel had with the P60/P66 processors Hth Colin Alfke Calgary Canada -Original Message- From: Piers Angliss [SNIP] Wide-zero is a Universe-specific feature so wouldn't affect UniData I'm baffled - adding additional prints to the code suggests that both variables are of equal length consisting of the same characters, that A-B = 0 but that A is greater than B. If you change the assignment of B to B = 4.58 - 4.59 then it works fine, but B = 0 - 0.01 still fails If you step through with the UniBasic debugger everything still appears the same, but this time it works correctly !! Any UniData gurus out there who can suggest an explanation ? Piers [SNIP] -Original Message- From: michael preece Posted on behalf of a colleague who wishes to remain nameless... UniBasic code that should work The results of the following code are proving to be troublesome: A = 4.57 + (-4.58) B = (-0.01) PRINT 'TEST ONE: ARE ':A:' AND ':B:' THE SAME? ': IF A = B THEN PRINT 'YES' END ELSE PRINT 'NO' END A = OCONV(A,'MD20') B = OCONV(B,'MD20') PRINT 'TEST TWO: ARE ':A:' AND ':B:' THE SAME? ': IF A = B THEN PRINT 'YES' END ELSE PRINT 'NO' END You would expect both tests to return 'YES', but in fact, only the second test returns 'YES'. TEST ONE: ARE -0.01 AND -0.01 THE SAME? NO TEST TWO: ARE -0.01 AND -0.01 THE SAME? YES --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] RE: UniBasic code that should work
This is an interesting issue. You can work around it by using the DROUND. I.E. A = DROUND(A, 2) Michael Rajkowski -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Piers Angliss Sent: Wednesday, March 29, 2006 1:52 AM To: u2-users@listserver.u2ug.org Cc: [EMAIL PROTECTED] Subject: RE: [U2] RE: UniBasic code that should work OP doesn't say which database, except that UniBasic suggests UniData and on my machine it works fine in Universe but as described in UniData (5.2.3 on RHL)! Wide-zero is a Universe-specific feature so wouldn't affect UniData I'm baffled - adding additional prints to the code suggests that both variables are of equal length consisting of the same characters, that A-B = 0 but that A is greater than B. If you change the assignment of B to B = 4.58 - 4.59 then it works fine, but B = 0 - 0.01 still fails If you step through with the UniBasic debugger everything still appears the same, but this time it works correctly !! Any UniData gurus out there who can suggest an explanation ? Piers -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Kevin King Sent: 29 March 2006 01:53 To: u2-users@listserver.u2ug.org Subject: [U2] RE: UniBasic code that should work Sounds like Universe and the WIDE0 setting again. Seems we've seen a lot of that kind of stuff in the past few months. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, March 28, 2006 5:48 PM To: u2users Subject: UniBasic code that should work Posted on behalf of a colleague who wishes to remain nameless... UniBasic code that should work The results of the following code are proving to be troublesome: A = 4.57 + (-4.58) B = (-0.01) PRINT 'TEST ONE: ARE ':A:' AND ':B:' THE SAME? ': IF A = B THEN PRINT 'YES' END ELSE PRINT 'NO' END A = OCONV(A,'MD20') B = OCONV(B,'MD20') PRINT 'TEST TWO: ARE ':A:' AND ':B:' THE SAME? ': IF A = B THEN PRINT 'YES' END ELSE PRINT 'NO' END You would expect both tests to return 'YES', but in fact, only the second test returns 'YES'. TEST ONE: ARE -0.01 AND -0.01 THE SAME? NO TEST TWO: ARE -0.01 AND -0.01 THE SAME? YES Is there something simple that I am missing? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups u2users group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/u2users -~--~~~~--~~--~--~--- -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.385 / Virus Database: 268.3.2/294 - Release Date: 3/27/2006 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] RE: UniBasic code that should work
This could be fixed by multiplying the number by 100 so that floating points aren't used at all. (If you know for sure you will never have more than 2 decimals) I'm assuming these are money amounts. I once saw a similar problem where a locate on a list of appartements for 1 would find appartment 1E0 as a match. (On Universe). --- Raymond DeGennaro II [EMAIL PROTECTED] wrote: At 07:35 -0700 2006/03/29, Kevin King wrote: Wow, Piers, absolutely true. I just ran on UD6PE and it fails exactly as described. I sounds like UniBASIC is doing proper floating point math and the example has hit one ore more values that are tough to represent exactly. If you concatenate a null to the end, then it works, Because now they're strings. but adding a zero to each side of the IF A = B THEN does not change the outcome. Back to floating point in-exactness I have no explanation, and it does scare me just a bit. I think folks coming from a C/Pascal background aren't too suprised. Back in those days, I regularly re-used a floatequal macro that just made sure that (a-b) was less than a defined tolerance value. I think that's part of the reason for the popularity of fixed point notation in the days before FPU's became ubiquitous. In Grad School, I had one project that suffered so much from floating point round off, that I had to switch to an arbitrary precision math library. All the math was done in Base256, so it was easy to just tack on an extra byte to get an extra digit of precision. Think School House Rock's Hey Little Twelve Toes times 21-1/3. Ray -- .=. | =-=-=-=-=-=-= Eagle Rock Information Systems Corp =-=-=-=-=-=-= | | -=-=-=-=-=-=- web and database business solutions -=-=-=-=-=-=- | | http://www.eriscorp.com mailto:[EMAIL PROTECTED] | |Midwest Regional Office: 815-547-0662 (voice) 815-547-0353 (Fax)| .=. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] RE: UniBasic code that should work
Colin, Thank you, I'd completely forgotten about Float.Precision. Changing from (the default) setting of zero to any of the other settings (1-4) sorts it out - although it took three passes through the HELP to understand some of the other implications. I'm just slightly amazed that something this simple fails on the default setting and that I don't recall seeing this in UniData before, but I must have because the LOGIN paras in my clients' production accounts include it - Doh !!! Piers -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: 29 March 2006 15:46 To: u2-users@listserver.u2ug.org Subject: RE: [U2] RE: UniBasic code that should work In UniData see HELP FLOAT.PRECISION. Here is a website that explains some of the problems with using floating point math: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] RE: UniBasic code that should work
This function is not in UV. Did the original question say they were using Unidata? - Original Message - From: Mike Rajkowski [EMAIL PROTECTED] To: u2-users@listserver.u2ug.org Sent: Wednesday, March 29, 2006 9:38 AM Subject: RE: [U2] RE: UniBasic code that should work This is an interesting issue. You can work around it by using the DROUND. I.E. A = DROUND(A, 2) Michael Rajkowski -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Piers Angliss Sent: Wednesday, March 29, 2006 1:52 AM To: u2-users@listserver.u2ug.org Cc: [EMAIL PROTECTED] Subject: RE: [U2] RE: UniBasic code that should work OP doesn't say which database, except that UniBasic suggests UniData and on my machine it works fine in Universe but as described in UniData (5.2.3 on RHL)! Wide-zero is a Universe-specific feature so wouldn't affect UniData I'm baffled - adding additional prints to the code suggests that both variables are of equal length consisting of the same characters, that A-B = 0 but that A is greater than B. If you change the assignment of B to B = 4.58 - 4.59 then it works fine, but B = 0 - 0.01 still fails If you step through with the UniBasic debugger everything still appears the same, but this time it works correctly !! Any UniData gurus out there who can suggest an explanation ? Piers -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Kevin King Sent: 29 March 2006 01:53 To: u2-users@listserver.u2ug.org Subject: [U2] RE: UniBasic code that should work Sounds like Universe and the WIDE0 setting again. Seems we've seen a lot of that kind of stuff in the past few months. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, March 28, 2006 5:48 PM To: u2users Subject: UniBasic code that should work Posted on behalf of a colleague who wishes to remain nameless... UniBasic code that should work The results of the following code are proving to be troublesome: A = 4.57 + (-4.58) B = (-0.01) PRINT 'TEST ONE: ARE ':A:' AND ':B:' THE SAME? ': IF A = B THEN PRINT 'YES' END ELSE PRINT 'NO' END A = OCONV(A,'MD20') B = OCONV(B,'MD20') PRINT 'TEST TWO: ARE ':A:' AND ':B:' THE SAME? ': IF A = B THEN PRINT 'YES' END ELSE PRINT 'NO' END You would expect both tests to return 'YES', but in fact, only the second test returns 'YES'. TEST ONE: ARE -0.01 AND -0.01 THE SAME? NO TEST TWO: ARE -0.01 AND -0.01 THE SAME? YES Is there something simple that I am missing? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups u2users group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/u2users -~--~~~~--~~--~--~--- -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.385 / Virus Database: 268.3.2/294 - Release Date: 3/27/2006 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/