dbTalk Databases Forums  

Flash/Non-flash Math problems

comp.databases.pick comp.databases.pick


Discuss Flash/Non-flash Math problems in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
DaveG
 
Posts: n/a

Default Flash/Non-flash Math problems - 11-08-2005 , 09:49 AM






I have had issues with math calculations exceeding the 2^32 barrier
when using flash compiled code. If I compile without flash, it
performs the calculation correctly. I have had to deal with this issue
several times. It looks pretty bad to the auditors when simple math
doesn't work correctly!

If I explicitly change to precision 0 it works - I'm assuming it just
raises the barrier. If I use parenthesis it works also.

Why should I have to be concerned about the contents (size) of
variables? Is there a way to force the Flash compiler to use a larger
numeric type when doing math besides lowering the precision?

Flashed: (no precision statement)
BUDGET= 27,000,000.00
DAYS = 365
INT(BUDGET * DAYS/365)= 2,322,741.76
INT(BUDGET * (DAYS/365))= 27,000,000.00


Non-Flashed:
BUDGET= 27,000,000.00
DAYS = 365
INT(BUDGET * DAYS/365)= 27,000,000.00
INT(BUDGET * (DAYS/365))= 27,000,000.00


Reply With Quote
  #2  
Old   
r.grosser56@comcast.net
 
Posts: n/a

Default Re: Flash/Non-flash Math problems - 11-08-2005 , 10:20 AM






If you're using D3, there are extended precision arithmetic and
comparative subroutines in DM,BP, that I've found handy for more
complex calcs.

I've used them very successfully.

They're called:

XDIVX
XADDX
XSUBX
XMULX
XCMPX
XABSX
XEXPX

Etc, etc......a quick look at the code involved will give you an idea
of what each routine does, aside from the self-explanatory ones above.


DaveG wrote:
Quote:
I have had issues with math calculations exceeding the 2^32 barrier
when using flash compiled code. If I compile without flash, it
performs the calculation correctly. I have had to deal with this issue
several times. It looks pretty bad to the auditors when simple math
doesn't work correctly!

If I explicitly change to precision 0 it works - I'm assuming it just
raises the barrier. If I use parenthesis it works also.

Why should I have to be concerned about the contents (size) of
variables? Is there a way to force the Flash compiler to use a larger
numeric type when doing math besides lowering the precision?

Flashed: (no precision statement)
BUDGET= 27,000,000.00
DAYS = 365
INT(BUDGET * DAYS/365)= 2,322,741.76
INT(BUDGET * (DAYS/365))= 27,000,000.00


Non-Flashed:
BUDGET= 27,000,000.00
DAYS = 365
INT(BUDGET * DAYS/365)= 27,000,000.00
INT(BUDGET * (DAYS/365))= 27,000,000.00


Reply With Quote
  #3  
Old   
Scott Ballinger
 
Posts: n/a

Default Re: Flash/Non-flash Math problems - 11-08-2005 , 11:17 AM



You could try compiling with the (of option to force use of floating
point math... however in my experience this may cause some arithmetic
operations to work differently than the [normal] fixed precision math.
Also, there may be issues with floating point enabled flash programs
calling or being called by non-floating point flash programs?

/Scott Ballinger
Pareto Corporaiton
Edmonds WA USA
206 713 6006


Reply With Quote
  #4  
Old   
r.grosser56@comcast.net
 
Posts: n/a

Default Re: Flash/Non-flash Math problems - 11-08-2005 , 11:47 AM



I meant to add that when using these subroutines compile fine with
flash.


Reply With Quote
  #5  
Old   
DaveG
 
Posts: n/a

Default Re: Flash/Non-flash Math problems - 11-08-2005 , 11:51 AM



Sorry - We are running D3 7.2.1 on Red Hat Linux.

All arithmetic is done in internal (no decimal places) format. The
results shown are OCONV'ed to MD2,


Reply With Quote
  #6  
Old   
DaveG
 
Posts: n/a

Default Re: Flash/Non-flash Math problems - 11-08-2005 , 01:28 PM



The (f option worked. This is the type of fix I was looking for - thank
you. I've added it to my options on the compile verb so everything
will be compile that way.

Are there any ramifications of using the f option for everything? Disk
space + memory are not an issue.


Reply With Quote
  #7  
Old   
Mark Brown
 
Posts: n/a

Default Re: Flash/Non-flash Math problems - 11-08-2005 , 03:26 PM



In NON-flashed Pick Basic, numbers are stored as strings until they need to
be used to calculate. If the string is too long, after adding precission
digits, to fit in 4 bytes, they use what's called String Math, so
theoritically there's no limit.

Flashed Pick Basic uses typed inters unless you use the F option, which then
types the variables as single precission floating point.

The problem on NT is that once you've done that, you are totally at the
mercy Microsoft math where 2 + 2 approaches 4 with very large values of 2.

It's fairly easy to write your own floating point math routines. I have a
set that I've tested to 100+ digits to either side of the decimal.

Mark Brown


"DaveG" <daveg_0205 (AT) iwon (DOT) com> wrote

Quote:
The (f option worked. This is the type of fix I was looking for - thank
you. I've added it to my options on the compile verb so everything
will be compile that way.

Are there any ramifications of using the f option for everything? Disk
space + memory are not an issue.




Reply With Quote
Reply




Thread Tools
Display Modes

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

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.