print ascii code of a character (ktoi)
This commit is contained in:
6
ml.cpp
6
ml.cpp
@@ -248,7 +248,8 @@ MlValue MlValue::cast_to_int() const {
|
||||
return *this;
|
||||
case FLOAT:
|
||||
return MlValue(long(stack_data.f));
|
||||
// Only ints and floats can be cast to an int
|
||||
case STRING:
|
||||
return MlValue(std::stol(str));
|
||||
default:
|
||||
throw MlError(*this, MlEnvironment(), BAD_CAST);
|
||||
}
|
||||
@@ -261,7 +262,8 @@ MlValue MlValue::cast_to_float() const {
|
||||
return *this;
|
||||
case INT:
|
||||
return MlValue(float(stack_data.i));
|
||||
// Only ints and floats can be cast to a float
|
||||
case STRING:
|
||||
return MlValue(std::stod(str));
|
||||
default:
|
||||
throw MlError(*this, MlEnvironment(), BAD_CAST);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user