Forum Stats

  • 3,853,829 Users
  • 2,264,280 Discussions
  • 7,905,459 Comments

Discussions

Convert decimal into base-25 format using OSB 11g

HarishG_TM
HarishG_TM Member Posts: 39 Blue Ribbon
edited May 13, 2015 2:50PM in XQuery

Hi All,

I want to Convert decimal numbers into base-25 format.


Can any one help me out here, how to implement this code using XQuery or OSB message Flow.

Thanks,

Harresh

Answers

  • odie_63
    odie_63 Member Posts: 8,493 Silver Trophy
    edited May 12, 2015 5:14PM

    Which digits do you have to use for this base-25 representation?

    0123456789ABCDEFGHIJKLMNO ?

    ABCDEFGHIJKLMNOPQRSTUVWXY ?

    Something else?

    For example, using a recursive XQuery function :

    declare function local:base25($n as xs:integer, $a as xs:string) as xs:string
    {
      let $digits := "0123456789ABCDEFGHIJKLMNO"
      let $q := $n idiv 25
      let $r := $n mod 25
      let $c := concat(substring($digits, $r+1, 1), $a)
      return if ($q = 0) then $c else local:base25($q, $c)
    };
    

    Usage : local:base25(1234567, "") will return "3407H".

This discussion has been closed.