ldmc/morphisms/real.morphism-base

105 lines
2.6 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```
#include <stdio.h>
```
morph_real_as_decimalstr_to_float ()
~ <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 ()
~ <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
--> ~ <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
--> ~ <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 ()
~ ~ native.UInt64
--> ~ native.Float
```
fprintf(stderr, "Warning: morphin UInt64 -> Float. Precision loss!");
*dst = *src;
return 0;
```
morph_real_as_u64_to_double ()
~ ~ 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: )
~ <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
--> ~ <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: )
~ <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
--> ~ <QuantizedLinear Begin End Steps> ~ ~ native.UInt64
```
*dst = ((*src - (double)Begin) * (double)Steps) / ((double)End - (double)Begin);
return 0;
```