RE: [Flashcoders] Number -- how good for use as an integer?

2007-03-06 Thread Douglas Pearson
Thanks guys for the responses.

I'm actually not concerned with arbitrary precision just storing a 32-bit
int (like a database key) and retrieving it accurately.  I guess the only
safe way in AS1/AS2 is to do the whole Math.round(value+0.01) thing.

Doug

-Original Message-
From: Jim Cheng [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 05, 2007 4:35 PM
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Number -- how good for use as an integer?

Douglas Pearson wrote:
> Can someone clarify whether Number is actually just a simple wrapper 
> round a double precision floating point value?
>
> Is this a problem with Flash?  If so, any solutions?

Internally, it's a 32-bit single precision float and doesn't play well if
you need arbitrary precision integer manipulations.  You can see the link
that Mick recommended for a longer discussion of this from Adobe.

This is a fairly common problem across many programming languages.  As such,
most developers needing such functionality (e.g. for financial, scientific
or cryptographic usages) resort to libraries providing for arbitrary
precision integer storage and operations.

While I don't know of any ActionScript specific libraries for this, there
are several that have been written for Javascript and shouldn't be too
difficult to port if you're so inclined.  Among others, see:

http://www.leemon.com/crypto/BigInt.html

http://www-cs-students.stanford.edu/~tjw/jsbn/

Jim Cheng
effectiveUI


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Number -- how good for use as an integer?

2007-03-05 Thread Jim Cheng

Douglas Pearson wrote:

Can someone clarify whether Number is actually just a simple wrapper round a
double precision floating point value?

Is this a problem with Flash?  If so, any solutions?


Internally, it's a 32-bit single precision float and doesn't play well 
if you need arbitrary precision integer manipulations.  You can see the 
link that Mick recommended for a longer discussion of this from Adobe.


This is a fairly common problem across many programming languages.  As 
such, most developers needing such functionality (e.g. for financial, 
scientific or cryptographic usages) resort to libraries providing for 
arbitrary precision integer storage and operations.


While I don't know of any ActionScript specific libraries for this, 
there are several that have been written for Javascript and shouldn't be 
too difficult to port if you're so inclined.  Among others, see:


http://www.leemon.com/crypto/BigInt.html

http://www-cs-students.stanford.edu/~tjw/jsbn/

Jim Cheng
effectiveUI
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Number -- how good for use as an integer?

2007-03-05 Thread Mick G

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_13989

I think you may have to put some Math.round(); around some of your values
just in case.




On 3/5/07, Douglas Pearson <[EMAIL PROTECTED]> wrote:


Can someone clarify whether Number is actually just a simple wrapper round
a
double precision floating point value?

The reason I'm asking is I'd like to know how accurately Flash can store
integers.  With AS3 there's a true "int" type added but in AS2 how
reliable
is Number at storing and retrieving integer values?

The problem here, of course, is that a floating point value can't exactly
represent integers (you get a lot of 1025.01 values instead of
1025).

Is this a problem with Flash?  If so, any solutions?

Doug

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Number -- how good for use as an integer?

2007-03-05 Thread Douglas Pearson
Can someone clarify whether Number is actually just a simple wrapper round a
double precision floating point value?

The reason I'm asking is I'd like to know how accurately Flash can store
integers.  With AS3 there's a true "int" type added but in AS2 how reliable
is Number at storing and retrieving integer values?

The problem here, of course, is that a floating point value can't exactly
represent integers (you get a lot of 1025.01 values instead of
1025).

Is this a problem with Flash?  If so, any solutions?

Doug

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com