1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

LibJS: Convert to_double() to ThrowCompletionOr

This commit is contained in:
Idan Horowitz 2021-10-16 22:11:08 +03:00 committed by Linus Groh
parent 51c33b3b35
commit 1639ed7e0a
10 changed files with 23 additions and 40 deletions

View file

@ -141,13 +141,13 @@ static ByteBuffer numeric_to_raw_bytes(GlobalObject& global_object, Value value,
swap(raw_bytes[i], raw_bytes[sizeof(UnderlyingBufferDataType) - 1 - i]);
};
if constexpr (IsSame<UnderlyingBufferDataType, float>) {
float raw_value = value.to_double(global_object);
float raw_value = MUST(value.to_double(global_object));
ReadonlyBytes { &raw_value, sizeof(float) }.copy_to(raw_bytes);
flip_if_needed();
return raw_bytes;
}
if constexpr (IsSame<UnderlyingBufferDataType, double>) {
double raw_value = value.to_double(global_object);
double raw_value = MUST(value.to_double(global_object));
ReadonlyBytes { &raw_value, sizeof(double) }.copy_to(raw_bytes);
flip_if_needed();
return raw_bytes;