Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
Format.cc
Go to the documentation of this file.
1 /*
2  * $Id: Format.cc 166 2013-07-01 08:30:55Z jdl3 $
3  * Copyright (C) 2013 John D Lamb
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or (at
8  * your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 # include<config.h>
22 #endif
23 
24 #include"Format.hpp"
25 
26 std::string
28  std::array<std::string,10> const
29  digits { { "₀","₁","₂","₃","₄","₅","₆","₇","₈","₉" } };
30  size_t remainder { subscript % 10 };
31  std::string result { digits[remainder] };
32  for( subscript /= 10; subscript != 0; subscript /= 10 ){
33  remainder = subscript % 10;
34  result = digits[remainder] + result;
35  }
36  return result;
37 }
38 
39 std::string
41  std::array<std::string,10> const
42  digits { { "⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹" } };
43  size_t remainder { superscript % 10 };
44  std::string result { digits[remainder] };
45  for( superscript /= 10; superscript != 0; superscript /= 10 ){
46  remainder = superscript % 10;
47  result = digits[remainder] + result;
48  }
49  return result;
50 }
std::string subscript(size_t subscript)
Create a string representing a subscript from a whole number.
Definition: Format.cc:27
std::string superscript(size_t superscript)
Create a string representing a superscript from a whole number.
Definition: Format.cc:40