[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: number of digits

Subject: Re: number of digits
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 22 May 2001 05:45:05 -0700 (PDT)
number of digits
> Is there any xsl function or trick to get the number of digits of a
> certain number ??

The solution depends on the number system used to represent the number and whether
the number is a whole integer or not:

1. Decimal

string-length($x) - (contains($x, '.')) - (contains($x, '-')) 

2. Hexadecimal integer

<digits:node>
  <digit>0</digit>
  <digit>16</digit>
  <digit>256</digit>
  <digit>4096</digit>
  <digit>65536</digit>
  <digit>1048576</digit>
  <digit>16777216</digit>
  <digit>268435456</digit>
  <digit>4294967296</digit>
  <digit>68719476736</digit>
  <digit>1099511627776</digit>
  <digit>17592186044416</digit>
  <digit>281474976710656</digit>
  <digit>4503599627370496</digit>
  <digit>72057594037927936</digit>
  <digit>1152921504606846976</digit>
</digits:node>

count($st/digits:node/digit[. > $x][1]/preceding-sibling::digit)

where the "st" variable is defined as:

<xsl:variable name="st" select="document('')/*"/>

3. Integer in another numeric system

The same as the above, only the "digits:node/digit" nodes should contain consecutive
powers of the base of the numeric system.


Cheers,
Dimitre Novatchev.

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.