OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [iwidgets3.0.0/] [generic/] [roman.itcl] - Rev 578

Go to most recent revision | Compare with Previous | Blame | View Log

namespace eval ::iwidgets {
  set romand(val)   {1000 900 500 400 100 90 50 40 10  9 5  4 1}
  set romand(upper) {   M  CM   D  CD   C XC  L XL  X IX V IV I}
  set romand(lower) {   m  cm   d  cd   c xc  l xl  x ix v iv i}

  proc roman2 {n {case upper}} {
      global romand
      set r ""
      foreach val $romand(val) sym $romand($case) {
          while {$n >= $val} {
              set r "$r$sym"
              incr n -$val
          }
      }
      return $r
  }
  
  proc roman {n {case upper}} {
      global romand
      set r ""
      foreach val $romand(val) sym $romand($case) {
          for {} {$n >= $val} {incr n -$val} {
              set r "$r$sym"
          }
      }
      return $r
  }
}

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.