ldmc/morphisms/real.morphism-base

91 lines
2.6 KiB
Text
Raw Normal View History

```
#include <stdio.h>
```
morph_real_as_decimalstr_to_float ()
2025-03-20 16:28:16 +01:00
~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
--> ~ native.Float32
```sscanf(src, "%f", dst);```
morph_real_as_decimalstr_to_double ()
2025-03-20 16:28:16 +01:00
~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
--> ~ native.Float64
```sscanf(src, "%lf", dst);```
morph_real_as_float_to_decimalstr ()
~ native.Float32
2025-03-20 16:28:16 +01:00
--> ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
```sprintf(dst, "%f", *src);```
morph_real_as_double_to_decimalstr ()
~ native.Float64
2025-03-20 16:28:16 +01:00
--> ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
```sprintf(dst, "%f", *src);```
morph_real_as_float_to_double ()
~ native.Float32
--> ~ native.Float64
```*dst = *src;```
morph_real_as_double_to_float ()
~ native.Float64
--> ~ native.Float32
```
fprintf(stderr, "Warning: morphin Double -> Float. Precision loss!");
*dst = *src;
```
morph_real_as_u64_to_float ()
2025-03-20 16:28:16 +01:00
~ ~ native.UInt64
--> ~ native.Float32
```
fprintf(stderr, "Warning: morphin UInt64 -> Float. Precision loss!");
*dst = *src;
```
morph_real_as_u64_to_double ()
2025-03-20 16:28:16 +01:00
~ ~ native.UInt64
--> ~ native.Float64
```
fprintf(stderr, "Warning: morphin UInt64 -> Double. Precision loss!");
*dst = *src;
```
morph_real_as_nat_to_quantized_linear ()
~ ~ native.UInt64
--> ~ <QuantizedLinear 0 1 1> ~ ~ native.UInt64
```
*dst = *src;
```
morph_real_as_quantized_linear_to_float (Begin: , End: , Steps: )
2025-03-20 16:28:16 +01:00
~ <QuantizedLinear Begin End Steps> ~ ~ native.UInt64
--> ~ native.Float32
```
*dst = (float)Begin + ( *src * ((float)End - (float)Begin) ) / (float)Steps;
```
morph_real_as_float_to_quantized_linear (Begin: , End: , Steps: )
~ native.Float32
2025-03-20 16:28:16 +01:00
--> ~ <QuantizedLinear Begin End Steps> ~ ~ native.UInt64
```
*dst = ((*src - (float)Begin) * (float)Steps) / ((float)End - (float)Begin);
```
morph_real_as_quantized_linear_to_double (Begin: , End: , Steps: )
2025-03-20 16:28:16 +01:00
~ <QuantizedLinear Begin End Steps> ~ ~ native.UInt64
--> ~ native.Float64
```
*dst = (double)Begin + ( *src * ((double)End - (double)Begin) ) / (double)Steps;
```
morph_real_as_double_to_quantized_linear (Begin: , End: , Steps: )
~ native.Float64
2025-03-20 16:28:16 +01:00
--> ~ <QuantizedLinear Begin End Steps> ~ ~ native.UInt64
```
*dst = ((*src - (double)Begin) * (double)Steps) / ((double)End - (double)Begin);
```