CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-14-2002, 04:02 PM
Lim Chee Beng's Avatar
Lim Chee Beng Lim Chee Beng is offline
Registered User
 
Join Date: Nov 2002
Location: Malaysia
Posts: 210
Question ME10 - Macro bug

When usually I compare 2 points in the ME10 macro program statement as.....
IF (P1<>(PNT_XY 2.46 4.13))
.....I found sometimes P1 can be intepreted as long decimal point of "2.46000001,4.13" (can't remember exactly how many zeros) even though it was originally assigned as "2.46,4.13". Consequently the result of comparison is always inconsistent and unpredictable.

The purpose of the comparison is to ensure P1 will be always exactly at location of "2.46,4.13". I also face the same problem when trying to verify 2 variable points are at the same location.

To prevent the problem, sometimes I'm forced to re-program as....
IF ((ROUND (P1*10000)/10000)<>(PNT_XY 2.46 4.13))
.....to truncate the tiny, meaningless and annoying decimal value.

Similar problem happens for floating point variable, I always have to re-program as.....
LET fpv (ROUND (fpv*1000000)/1000000)
.....to truncate the tiny decimal value of fpv variable.

Is there any simple programmatic way or internal ME10 configuration to fix the problem?

Reply With Quote
  #2  
Old 11-15-2002, 12:27 AM
Michael Kahle's Avatar
Michael Kahle Michael Kahle is offline
Registered User
 
Join Date: Oct 2002
Posts: 121
Comparing of numbers

I usally use something like
(ABS (Pkt1 - Pkt2)) < 1E-6

Regards,
Michael
Reply With Quote
  #3  
Old 11-15-2002, 05:31 AM
ChrisE's Avatar
ChrisE ChrisE is offline
OneSpace Member
 
Join Date: Oct 2002
Location: Grünstadt, Pfalz, Germany
Posts: 121
ME10 - Macro bug

Hi guys,

I have seen such code quite often where people try to compare floating point numbers using "=" (or something similar)

With older versions of ME10, this could have worked.
!!! BUT THIS IS QUITE DANGEROUS !!!

Floating point numbers (or points) should always be compared by subtracting them from each other, and checking the positive result against some epsilon value
Example:

IF ((ABS (X2-X1)) < 1E-6)
DISPLAY "X2 equals (closely) X1"
END_IF

Chris
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:05 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.