Announcement

Collapse
No announcement yet.

Price display - 5 digits

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Price display - 5 digits

    I am converting price using
    sStr = close(); //close = $18.50

    However, sStr contains extra zeros (e.g. 1850000000).

    I will appreciate if someone can show how to truncate extra zeros
    from the sStr display (or display only first 5 digits).

    Also how to separate decimal and integer parts in sStr.

    Thanks,

  • #2
    Micro2:

    Sstr = close().toFixed(5);

    will give you the 5 digits of precision

    Sstr = Math.floor( 12.54 ); // equals 12

    will round down to the nearest integer

    Sstr = Math.ceil( 12.54 ); // equals 13

    will round up to the nearest integer

    Sstr = Math.round( 12.54 ); // equals 13

    will perform the standard rounding function

    function Frac( nvalue ) {
    var x = Math.floor( nvalue );
    return( nvalue-x );
    }

    above function returns the fractional portion of a real number.

    Chris

    Comment

    Working...
    X