Skip to content

Commit

Permalink
- Fix for intMod (should only return positive results)
Browse files Browse the repository at this point in the history
- Change for realString (same precision as RML so rtest diffs are smaller)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7151 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 22, 2010
1 parent c565abe commit cc0d565
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions Compiler/Inst.mo
Expand Up @@ -14515,6 +14515,7 @@ algorithm
case (_,_)
equation
print("- Inst.add failed\n");
print(dumpTuple(entry));
then
fail();
end matchcontinue;
Expand Down
10 changes: 5 additions & 5 deletions c_runtime/meta_modelica_builtin.cpp
Expand Up @@ -93,7 +93,7 @@ intDiv_rettype intDiv(modelica_integer i1, modelica_integer i2)

intMod_rettype intMod(modelica_integer i1, modelica_integer i2)
{
return i1%i2;
return ((unsigned long) i1) % ((unsigned long) i2);
}

intMax_rettype intMax(modelica_integer i1, modelica_integer i2)
Expand Down Expand Up @@ -129,7 +129,7 @@ modelica_metatype boxptr_intDiv(modelica_metatype i1, modelica_metatype i2)

modelica_metatype boxptr_intMod(modelica_metatype i1, modelica_metatype i2)
{
return (void*) ((long)i1%(long)i2);
return (void*) ((unsigned long)i1%(unsigned long)i2);
}

modelica_metatype boxptr_intMax(modelica_metatype i1, modelica_metatype i2)
Expand Down Expand Up @@ -189,9 +189,9 @@ intReal_rettype intReal(modelica_integer i)

intString_rettype intString(modelica_integer i)
{
/* 32-bit integer: 1+log_10(2**31)+1 = 12 digits max */
static char buffer[12];
sprintf(buffer, "%d", i);
/* 64-bit integer: 1+log_10(2**63)+1 = 20 digits max */
static char buffer[32];
sprintf(buffer, "%ld", i);
return strdup(buffer);
}

Expand Down
2 changes: 1 addition & 1 deletion c_runtime/meta_modelica_real.cpp
Expand Up @@ -135,7 +135,7 @@ realString_rettype realString(modelica_real r)
res = "NaN";
else {
char* endptr;
int ix = snprintf(buffer, 32, "%.16g", r);
int ix = snprintf(buffer, 32, "%.15g", r);
long ignore;
if (ix < 0)
throw 1;
Expand Down

0 comments on commit cc0d565

Please sign in to comment.