ldmc/morphisms/real.morphism-base

106 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.Float
```
sscanf(src, "%f", dst);
return 0;
```
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.Double
```
sscanf(src, "%lf", dst);
return 0;
```
morph_real_as_float_to_decimalstr ()
~ native.Float
2025-03-20 16:28:16 +01:00
--> ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
```
sprintf(dst, "%f", *src);
return 0;
```
morph_real_as_double_to_decimalstr ()
~ native.Double
2025-03-20 16:28:16 +01:00
--> ~ <PosInt 10 BigEndian> ~ <Seq~<ValueTerminated 0> <Digit 10>~Char~Ascii~native.UInt8>
```
sprintf(dst, "%f", *src);
return 0;
```
morph_real_as_float_to_double ()
~ native.Float
--> ~ native.Double
```
*dst = *src;
return 0;
```
morph_real_as_double_to_float ()
~ native.Double
--> ~ native.Float
```
fprintf(stderr, "Warning: morphin Double -> Float. Precision loss!");
*dst = *src;
return 0;
```
morph_real_as_u64_to_float ()
2025-03-20 16:28:16 +01:00
~ ~ native.UInt64
--> ~ native.Float
```
fprintf(stderr, "Warning: morphin UInt64 -> Float. Precision loss!");
*dst = *src;
return 0;
```
morph_real_as_u64_to_double ()
2025-03-20 16:28:16 +01:00
~ ~ native.UInt64
--> ~ native.Double
```
fprintf(stderr, "Warning: morphin UInt64 -> Double. Precision loss!");
*dst = *src;
return 0;
```
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.Float
```
*dst = (float)Begin + ( *src * ((float)End - (float)Begin) ) / (float)Steps;
return 0;
```
morph_real_as_float_to_quantized_linear (Begin: , End: , Steps: )
~ native.Float
2025-03-20 16:28:16 +01:00
--> ~ <QuantizedLinear Begin End Steps> ~ ~ native.UInt64
```
*dst = ((*src - (float)Begin) * (float)Steps) / ((float)End - (float)Begin);
return 0;
```
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.Double
```
*dst = (double)Begin + ( *src * ((double)End - (double)Begin) ) / (double)Steps;
return 0;
```
morph_real_as_double_to_quantized_linear (Begin: , End: , Steps: )
~ native.Double
2025-03-20 16:28:16 +01:00
--> ~ <QuantizedLinear Begin End Steps> ~ ~ native.UInt64
```
*dst = ((*src - (double)Begin) * (double)Steps) / ((double)End - (double)Begin);
return 0;
```