Discrepancy in Results from Mathematically Equivalent Programs in SOFiSTiK Teddy

I am encountering an issue in SOFiSTiK Teddy where two mathematically equivalent programs produce different results. Here are the two programs:

Program 1:
let#AbstUnteElem DIV(#SpglAufl_PosU(#AbstHaltNr)/((#Hoehe(#1+2)-#Hoehe(#1+1))/#VER))+IIF(MOD(#SpglAufl_PosU(#AbstHaltNr)/((#Hoehe(#1+2)-#Hoehe(#1+1))/#VER))>=0.5,1,0)
sto#SpglHoehe(#1+1) #Hoehe(#1+2)-#AbstUnteElem*((#Hoehe(#1+2)-#Hoehe(#1+1))/#VER)

let#Rad (#Durchm(#1+1)+(#SpglHoehe(#1+1)-#Hoehe(#1+1))((#Durchm(#1+2)-#Durchm(#1+1))/(#Hoehe(#1+2)-#Hoehe(#1+1))))/2
let#Dic (#Dicke(#1+1)+(#SpglHoehe(#1+1)-#Hoehe(#1+1))
((#Dicke(#1+2)-#Dicke(#1+1))/(#Hoehe(#1+2)-#Hoehe(#1+1))))
sto#SpglRadius(#1+1) #Rad-#Dic-#SpanngHullroDurc/2-#SpglAufl_Abst(#AbstHaltNr) ;

Program 2:
let#AbstUnteElem DIV(#SpglAufl_PosU(#AbstHaltNr)/((#Hoehe(#1+2)-#Hoehe(#1+1))/#VER))+IIF(MOD(#SpglAufl_PosU(#AbstHaltNr)/((#Hoehe(#1+2)-#Hoehe(#1+1))/#VER))>=0.5,1,0)
sto#SpglHoehe(#1+1) #Hoehe(#1+2)-#AbstUnteElem*((#Hoehe(#1+2)-#Hoehe(#1+1))/#VER)
sto#SpglRadius(#1+1) (#Durchm(#1+1)+(#SpglHoehe(#1+1)-#Hoehe(#1+1))((#Durchm(#1+2)-#Durchm(#1+1))/(#Hoehe(#1+2)-#Hoehe(#1+1))))/2 $$
-(#Dicke(#1+1)+(#SpglHoehe(#1+1)-#Hoehe(#1+1))
((#Dicke(#1+2)-#Dicke(#1+1))/(#Hoehe(#1+2)-#Hoehe(#1+1)))) $$
-#SpanngHullroDurc/2 $$
-#SpglAufl_Abst(#AbstHaltNr) ;

Despite the mathematical equivalence of these programs, SOFiSTiK produces different results.

Could someone help explain why this discrepancy occurs and if there are any specific considerations or best practices we should follow when programming in SOFiSTiK Teddy?

Thank you in advance for your assistance!

Line continuation ($$) can’t be used in the middle of an arithmetic expression (program 2).
The subsequent lines are interpreted as the subsequent positions in the vector.

Your code is equivalent to (extra line breaks for readability):

sto#SpglRadius(#1+1)
(#Durchm(#1+1)+(#SpglHoehe(#1+1)-#Hoehe(#1+1))((#Durchm(#1+2)-#Durchm(#1+1))/(#Hoehe(#1+2)-#Hoehe(#1+1))))/2

sto#SpglRadius(#1+2)
-(#Dicke(#1+1)+(#SpglHoehe(#1+1)-#Hoehe(#1+1))((#Dicke(#1+2)-#Dicke(#1+1))/(#Hoehe(#1+2)-#Hoehe(#1+1))))

sto#SpglRadius(#1+3)
-#SpanngHullroDurc/2

sto#SpglRadius(#1+4)
-#SpglAufl_Abst(#AbstHaltNr)

1 Like

thank you. That really explains the reason!

another question: this means I can’t use line break here? or it doesn’t matter to use line break (without $$) in the programm?

Line breaks are ok when entering a record, e.g. in sofimshc :
Spt No 101 $$
X 10 $$
Y 5 $$
Z 26

But calculating a numeric must be done in one row.
The workaround is to save partial results in intermediate variables (i.e. your program 1)

1 Like