Spostata qui la funzione setdec
git-svn-id: svn://10.65.10.50/trunk@3669 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
103b090f46
commit
4c1ad8273a
@ -104,8 +104,95 @@ HIDDEN void __getfieldbuff(int l, int t, const char* recin, char *s)
|
|||||||
strcpy(s," ");
|
strcpy(s," ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setdec(char * s,int dec)
|
||||||
|
{
|
||||||
|
char *s1;
|
||||||
|
int i, l, carry;
|
||||||
|
|
||||||
|
if (strlen(s) == 0) strcpy(s, "0");
|
||||||
|
if ((s1 = strchr(s, ',')) != NULL) *s1 = '.';
|
||||||
|
s1 = strchr(s, '.');
|
||||||
|
if ((dec) && (s1 == NULL))
|
||||||
|
{
|
||||||
|
strcat(s, ".");
|
||||||
|
s1 = strchr(s, '.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (!dec)
|
||||||
|
{
|
||||||
|
if (s1 == NULL) return ;
|
||||||
|
l = strlen(s1); /* occhio verificare */
|
||||||
|
carry = (s1[1] >= '5');
|
||||||
|
*s1 = '\0';
|
||||||
|
while (carry)
|
||||||
|
{
|
||||||
|
s1--;
|
||||||
|
if (*s1 == '-') break;
|
||||||
|
if (*s1 == '9')
|
||||||
|
{
|
||||||
|
*s1 = '0';
|
||||||
|
if (s == s1) break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(*s1)++;
|
||||||
|
carry = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (carry)
|
||||||
|
{
|
||||||
|
for (i = l; i > (*s1 == '-'); i--) s[i] = s[i - 1];
|
||||||
|
s[(*s1 == '-')] = '1';
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
s1++;
|
||||||
|
l = strlen(s1);
|
||||||
|
if (l > dec)
|
||||||
|
{
|
||||||
|
carry = (s1[dec] >= '5');
|
||||||
|
s1[dec] = '\0';
|
||||||
|
while (carry)
|
||||||
|
{
|
||||||
|
dec--;
|
||||||
|
if (s1[dec] == '9')
|
||||||
|
{
|
||||||
|
s1[dec] = '0';
|
||||||
|
if (!dec) break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s1[dec]++;
|
||||||
|
carry = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s1--;
|
||||||
|
while (carry)
|
||||||
|
{
|
||||||
|
s1--;
|
||||||
|
if (*s1 == '-') break;
|
||||||
|
if (*s1 == '9')
|
||||||
|
{
|
||||||
|
*s1 = '0';
|
||||||
|
if (s == s1) break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(*s1)++;
|
||||||
|
carry = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (carry)
|
||||||
|
{
|
||||||
|
for (i = l; i > (*s1 == '-'); i--) s[i] = s[i - 1];
|
||||||
|
s[(*s1 == '-')] = '1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
while (l++ < dec) strcat(s1, "0");
|
||||||
|
}
|
||||||
|
|
||||||
HIDDEN void __putfieldbuff(int l, int d, int t, const char* s, char* recout)
|
HIDDEN void __putfieldbuff(int l, int d, int t, const char* s, char* recout)
|
||||||
{
|
{
|
||||||
@ -168,7 +255,8 @@ HIDDEN void __putfieldbuff(int l, int d, int t, const char* s, char* recout)
|
|||||||
strncpy(recout, s2, len) ;
|
strncpy(recout, s2, len) ;
|
||||||
while (len < l) recout[len++] = ' ';
|
while (len < l) recout[len++] = ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TRic_recfield::TRic_recfield(TRectype& rec, const char* name, int from, int len)
|
TRic_recfield::TRic_recfield(TRectype& rec, const char* name, int from, int len)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user