benibus commented on code in PR #36073: URL: https://github.com/apache/arrow/pull/36073#discussion_r1286310533
########## cpp/src/arrow/util/float16.h: ########## @@ -0,0 +1,198 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include <array> +#include <cstdint> +#include <cstring> +#include <iosfwd> +#include <limits> +#include <type_traits> + +#include "arrow/util/endian.h" +#include "arrow/util/ubsan.h" +#include "arrow/util/visibility.h" + +namespace arrow { +namespace util { + +/// \brief Base class for an IEEE half-precision float, encoded as a `uint16_t` +/// +/// The exact format is as follows (from MSB to LSB): +/// - bit 0: sign +/// - bits 1-5: exponent +/// - bits 6-15: mantissa +/// +/// NOTE: Methods in the class should not mutate the unerlying value or produce copies. Review Comment: Honestly, the only reason for the base class was to make testing on the Parquet side more convenient, since the value data needs to be stored externally (see `BufferedFloat16` [here](https://github.com/apache/arrow/blob/2f06b0b0577f53547da9bc471d69c49749ae8e89/cpp/src/parquet/statistics_test.cc#L66)). I'm not sure if this is a good enough justification for a public API though - and I agree that a single class would be better, so I'll try a different approach for the tests. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
