added: option 'group_digits' to Conv struct
you can set how many digits should be grouped git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@338 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
c51b2fdcc9
commit
231164f6ea
|
@ -1,9 +1,11 @@
|
|||
Version 0.9.3 prerelease (2010.09.29):
|
||||
Version 0.9.3 prerelease (2011.01.30):
|
||||
* added: Parser::InitCGamma()
|
||||
initializing coefficients used when calculating the gamma (or factorial) function
|
||||
this speed up the next calculations
|
||||
you don't have to call this method explicitly
|
||||
these coefficients will be calculated when needed
|
||||
* added: option 'group_digits' to Conv struct
|
||||
you can set how many digits should be grouped
|
||||
|
||||
|
||||
Version 0.9.2 (2010.09.23):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2006-2010, Tomasz Sowa
|
||||
Copyright (c) 2006-2011, Tomasz Sowa
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2010, Tomasz Sowa
|
||||
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -4738,15 +4738,19 @@ private:
|
|||
typename string_type::size_type & index) const
|
||||
{
|
||||
typedef typename string_type::size_type StrSize;
|
||||
uint group = 0;
|
||||
|
||||
|
||||
uint group = 0;
|
||||
StrSize i = index;
|
||||
uint group_digits = conv.group_digits;
|
||||
|
||||
if( group_digits < 1 )
|
||||
group_digits = 1;
|
||||
|
||||
// adding group characters before the comma operator
|
||||
// i>0 because on the first position we don't put any additional grouping characters
|
||||
for( ; i>0 ; --i, ++group)
|
||||
{
|
||||
if( group >= 3 )
|
||||
if( group >= group_digits )
|
||||
{
|
||||
group = 0;
|
||||
new_man.insert(i, 1, static_cast<char_type>(conv.group));
|
||||
|
@ -4763,11 +4767,15 @@ private:
|
|||
void ToString_Group_man_after_comma(string_type & new_man, const Conv & conv,
|
||||
typename string_type::size_type index) const
|
||||
{
|
||||
uint group = 0;
|
||||
uint group = 0;
|
||||
uint group_digits = conv.group_digits;
|
||||
|
||||
if( group_digits < 1 )
|
||||
group_digits = 1;
|
||||
|
||||
for( ; index<new_man.size() ; ++index, ++group)
|
||||
{
|
||||
if( group >= 3 )
|
||||
if( group >= group_digits )
|
||||
{
|
||||
group = 0;
|
||||
new_man.insert(index, 1, static_cast<char_type>(conv.group));
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2010, Tomasz Sowa
|
||||
* Copyright (c) 2006-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -465,6 +465,13 @@ namespace ttmath
|
|||
uint group;
|
||||
|
||||
|
||||
/*!
|
||||
how many digits should be grouped (it is used if 'group' is non zero)
|
||||
default: 3
|
||||
*/
|
||||
uint group_digits;
|
||||
|
||||
|
||||
/*!
|
||||
*/
|
||||
uint group_exp; // not implemented yet
|
||||
|
@ -484,6 +491,7 @@ namespace ttmath
|
|||
comma = '.';
|
||||
comma2 = ',';
|
||||
group = 0;
|
||||
group_digits = 3;
|
||||
group_exp = 0;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3225,7 +3225,8 @@ private:
|
|||
{
|
||||
temp.DivInt(b, &rem);
|
||||
character = static_cast<char>( Misc::DigitToChar(rem) );
|
||||
result.insert(result.begin(), character);
|
||||
result.insert(result.begin(), character); // !! it has O(n^2) complexity, change it
|
||||
// take the one from winix
|
||||
}
|
||||
while( !temp.IsZero() );
|
||||
|
||||
|
|
Loading…
Reference in New Issue