We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ce546f6 commit fafd843Copy full SHA for fafd843
vm/src/builtins/float.rs
@@ -204,6 +204,24 @@ impl PyFloat {
204
}
205
206
207
+ #[pymethod(magic)]
208
+ fn getformat(&self, spec: PyStrRef, vm: &VirtualMachine) -> PyResult<String> {
209
+ if !matches!(spec.as_str(), "double" | "float") {
210
+ return Err(vm.new_value_error(
211
+ "__getformat__() argument 1 must be 'double' or 'float'".to_owned(),
212
+ ));
213
+ }
214
+
215
+ const BIG_ENDIAN: bool = cfg!(target_endian = "big");
216
217
+ Ok(if BIG_ENDIAN {
218
+ "IEEE, big-endian"
219
+ } else {
220
+ "IEEE, little-endian"
221
222
+ .to_owned())
223
224
225
#[pymethod(magic)]
226
fn abs(&self) -> f64 {
227
self.value.abs()
0 commit comments