49.95 * 3 = 149.85000000000002?

49.95 * 3 = 149.85000000000002?

Post by phree » Fri, 04 Jul 2008 22:27:32


Maybe what you are looking for is a means of formatting numbers.
Here is a function that I use (based on a function from "ActionScript
Cookbook".
What would be nice would be an ActionScript implementation of the Java
format routines.
http://www.yqcomputer.com/

public function NumberFormat(num:Number,
thousandsDelim:String, decimalDelim:String,
fieldWidth:int, fractionSize:int):String
{
// Default to a comma for thousands and a period for decimals.
if (thousandsDelim.length < 1) {thousandsDelim = ",";}
if (decimalDelim.length < 1) {decimalDelim= ".";}

// Convert the number to strings splitting it at the decimal point.
var parts:Array = String(num).split(".");

// Anticipating inserting the thousands delimiters,
// store the whole portion as an array of single characters
// in reverse order.
var partOneAr:Array = parts[0].split("");

// Insert the thousands delimiter after every third character.
for (var ix:int = partOneAr.length-1, counter:int = 0; ix >= 0;
ix--, counter++) {
if (counter < 3) continue
counter = 0;
partOneAr.splice(ix+1, 0, thousandsDelim);
}

var fraction:String;
if (fractionSize > 0) {
var fad:String;
for (var kx:int = 0; kx < fractionSize; kx++) {
fad += "0";
}
fraction = (decimalDelim + parts[1] + fad).substring(0,fractionSize
+1);
}
// Reverse the array again so that it is back in the original order.
var val:String = partOneAr.join("") + fraction;

// If fieldWidth is defined, add the necessary number of leading
spaces.
if (fieldWidth > 0) {
var origLength:int = val.length;
var pad:String;
for (var jx:int = 0; jx < fieldWidth - origLength; jx++) {
pad += " ";
}
val = pad + val;
}
return val;
};
 
 
 

1. Incredible JPrintout Christmas Discount - 75% !!! Only 49.95 for professional java reporting package with support.

2. Incredible JPrintout Christmas Discount - 75% !!! Only 49.95 for professional java reporting package with support.

Incredible JPrintout Christmas Discount - 75% !!! Only 49.95 for
professional java reporting package with support.

JPRINTOUT - EMBEDDED PROFESSIONAL REPORTING. With flash demos!

JPrintout - professional reporting embedded in your java application.
With set of flash demos it takes only several minutes to catch up main
stream of using software, learn principal features, and get intuitive
grasp to start using it straightway even without reading help!

JPrintOut is an easy-to-use XML-based professional java reporting
solution for creating rich sophisticated reports from any data source
quickly and efficiently, and embed it in java application. It includes
all the tools and technologies you need to create reports satisfying
all your requirements, and embed it into your java application. With
developed thought-out architecture, advanced-featured designer
available at runtime, up-to-date band-oriented report generator,
embedded powerful like-java script language, and detailed error
messaging system, JPrintOut gives user full control over the report.
JPrintOut can be used in all kinds of java applications - standalone
GUI
written with swing, or server side systems. With set of output formats
available you can easily embed report into the web page.
With set of flash demos it takes only several minutes to catch up main
stream of using software, learn principal features, and get intuitive
grasp to start using it straightway even without reading help!


Visit our web site http://www.yqcomputer.com/

3. Incredible JPrintout Christmas Discount - 75% !!! Only 49.95 for professional java reporting package with support

4. Incredible JPrintout Christmas Discount - 75% !!! Only 49.95 for professional java reporting package with support.