Skip to content

Commit

Permalink
Trim precision for every functional operation in 2D interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
IKhonakhbeeva committed Feb 22, 2024
1 parent 8720120 commit f5950f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ void TrikPrintTextBlock::doJob(kitBase::robotModel::robotParts::Display &display
const int x = eval<int>("XCoordinateText");
const int y = eval<int>("YCoordinateText");
const int fontSize = eval<int>("FontSize");
const QString result = boolProperty("Evaluate")
? QString::number(QString::number(eval<qreal>("PrintText"), 'f', 6).toDouble())
: stringProperty("PrintText");
const QString result = boolProperty("Evaluate") ? eval<QString>("PrintText") : stringProperty("PrintText");
const bool redraw = boolProperty("Redraw");

if (!errorsOccured()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ void PrintTextBlock::doJob(kitBase::robotModel::robotParts::Display &display)
{
const int x = eval<int>("XCoordinateText");
const int y = eval<int>("YCoordinateText");
const QString result = boolProperty("Evaluate")
? QString::number(QString::number(eval<qreal>("PrintText"), 'f', 6).toDouble())
: stringProperty("PrintText");
const QString result = boolProperty("Evaluate") ? eval<QString>("PrintText") : stringProperty("PrintText");
const bool redraw = boolProperty("Redraw");

if (!errorsOccured()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ void RobotsBlockParser::addIntrinsicFuctions()
, std::function<qreal(qreal)> const &function)
{
add1aryFunction(name, new types::Float, new types::Float
, [function](const QVariant &arg) { return function(arg.toReal()); });
, [function](const QVariant &arg) {
return QString::number(function(arg.toReal()), 'f').toDouble();
});
};

const auto addIntegerFunction = [add1aryFunction] (const QString &name
Expand Down

0 comments on commit f5950f7

Please sign in to comment.