Skip to content

Commit

Permalink
22800: Fixes an issue where the absolute value of (null) returns zero (
Browse files Browse the repository at this point in the history
  • Loading branch information
cademack authored Feb 12, 2025
1 parent e3f753e commit cc142b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Amalgam/entity/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class Entity
//Evaluates the specified label into a string and puts the value in value_out.
//If the label exists, sets value_out to the value and returns true.
// Otherwise sets value_out to empty string and returns false
std::pair<std::string,bool> GetValueAtLabelAsString(StringInternPool::StringID label_sid, bool on_self = false);
std::pair<std::string, bool> GetValueAtLabelAsString(StringInternPool::StringID label_sid, bool on_self = false);

//Evaluates the specified label into a EvaluableNodeImmediateValueWithType
//if destination_temp_enm is not null and code is needed, it will make a copy
Expand Down
4 changes: 3 additions & 1 deletion src/Amalgam/interpreter/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ class Interpreter
return InterpretNode(n, immediate_result);
}

//computes a unary numeric function on the given node
//computes a unary numeric function on the given node, returns an ENT_NULL if n is interpreted as an ENT_NULL
__forceinline EvaluableNodeReference InterpretNodeUnaryNumericOperation(EvaluableNode *n, bool immediate_result,
std::function<double(double)> func)
{
Expand All @@ -526,6 +526,8 @@ class Interpreter
}

auto retval = InterpretNodeIntoUniqueNumberValueOrNullEvaluableNode(n);
if(retval->GetType() == ENT_NULL)
return retval;
double value = retval->GetNumberValue();
double result = func(value);
retval->SetTypeViaNumberValue(result);
Expand Down

0 comments on commit cc142b2

Please sign in to comment.