Norimasa Okamoto
/
pymite
python-on-a-chip online compiler
- http://pymbed.appspot.com/
- https://code.google.com/p/python-on-a-chip/
- http://www.youtube.com/watch?v=Oyqc2bFRW9I
- https://bitbucket.org/va009039/pymbed/
more info: python-on-a-chip
vm/float.h@15:94ca5c8003e5, 2016-04-14 (annotated)
- Committer:
- va009039
- Date:
- Thu Apr 14 22:32:57 2016 +0000
- Revision:
- 15:94ca5c8003e5
- Parent:
- 0:65f1469d6bfb
update Nucleo-F401RE.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:65f1469d6bfb | 1 | /* |
va009039 | 0:65f1469d6bfb | 2 | # This file is Copyright 2009 Dean Hall. |
va009039 | 0:65f1469d6bfb | 3 | # This file is part of the PyMite VM. |
va009039 | 0:65f1469d6bfb | 4 | # This file is licensed under the MIT License. |
va009039 | 0:65f1469d6bfb | 5 | # See the LICENSE file for details. |
va009039 | 0:65f1469d6bfb | 6 | */ |
va009039 | 0:65f1469d6bfb | 7 | |
va009039 | 0:65f1469d6bfb | 8 | |
va009039 | 0:65f1469d6bfb | 9 | #ifndef __FLOAT_H__ |
va009039 | 0:65f1469d6bfb | 10 | #define __FLOAT_H__ |
va009039 | 0:65f1469d6bfb | 11 | |
va009039 | 0:65f1469d6bfb | 12 | |
va009039 | 0:65f1469d6bfb | 13 | /** |
va009039 | 0:65f1469d6bfb | 14 | * \file |
va009039 | 0:65f1469d6bfb | 15 | * \brief Float Object Type |
va009039 | 0:65f1469d6bfb | 16 | * |
va009039 | 0:65f1469d6bfb | 17 | * Float object type header. |
va009039 | 0:65f1469d6bfb | 18 | */ |
va009039 | 0:65f1469d6bfb | 19 | |
va009039 | 0:65f1469d6bfb | 20 | |
va009039 | 0:65f1469d6bfb | 21 | /** |
va009039 | 0:65f1469d6bfb | 22 | * Float obj |
va009039 | 0:65f1469d6bfb | 23 | * |
va009039 | 0:65f1469d6bfb | 24 | * 32b floating point number |
va009039 | 0:65f1469d6bfb | 25 | */ |
va009039 | 0:65f1469d6bfb | 26 | typedef struct PmFloat_s |
va009039 | 0:65f1469d6bfb | 27 | { |
va009039 | 0:65f1469d6bfb | 28 | /** Object descriptor */ |
va009039 | 0:65f1469d6bfb | 29 | PmObjDesc_t od; |
va009039 | 0:65f1469d6bfb | 30 | |
va009039 | 0:65f1469d6bfb | 31 | /** Float value */ |
va009039 | 0:65f1469d6bfb | 32 | float val; |
va009039 | 0:65f1469d6bfb | 33 | } PmFloat_t, *pPmFloat_t; |
va009039 | 0:65f1469d6bfb | 34 | |
va009039 | 0:65f1469d6bfb | 35 | |
va009039 | 0:65f1469d6bfb | 36 | #ifdef HAVE_FLOAT |
va009039 | 0:65f1469d6bfb | 37 | |
va009039 | 0:65f1469d6bfb | 38 | /** |
va009039 | 0:65f1469d6bfb | 39 | * Creates a new Float object |
va009039 | 0:65f1469d6bfb | 40 | * |
va009039 | 0:65f1469d6bfb | 41 | * @param f Value to assign float (signed 32-bit). |
va009039 | 0:65f1469d6bfb | 42 | * @param r_pint Return by ref, ptr to new float |
va009039 | 0:65f1469d6bfb | 43 | * @return Return status |
va009039 | 0:65f1469d6bfb | 44 | */ |
va009039 | 0:65f1469d6bfb | 45 | PmReturn_t float_new(float f, pPmObj_t *r_pf); |
va009039 | 0:65f1469d6bfb | 46 | |
va009039 | 0:65f1469d6bfb | 47 | /** |
va009039 | 0:65f1469d6bfb | 48 | * Implements the UNARY_NEGATIVE bcode. |
va009039 | 0:65f1469d6bfb | 49 | * |
va009039 | 0:65f1469d6bfb | 50 | * Creates a new float with a value that is the negative of the given float. |
va009039 | 0:65f1469d6bfb | 51 | * |
va009039 | 0:65f1469d6bfb | 52 | * @param pobj Pointer to target object |
va009039 | 0:65f1469d6bfb | 53 | * @param r_pint Return by ref, ptr to float |
va009039 | 0:65f1469d6bfb | 54 | * @return Return status |
va009039 | 0:65f1469d6bfb | 55 | */ |
va009039 | 0:65f1469d6bfb | 56 | PmReturn_t float_negative(pPmObj_t pf, pPmObj_t *r_pf); |
va009039 | 0:65f1469d6bfb | 57 | |
va009039 | 0:65f1469d6bfb | 58 | /** |
va009039 | 0:65f1469d6bfb | 59 | * Returns by reference a float that is x op y. |
va009039 | 0:65f1469d6bfb | 60 | * |
va009039 | 0:65f1469d6bfb | 61 | * @param px The float left-hand argument |
va009039 | 0:65f1469d6bfb | 62 | * @param py The float right-hand argument |
va009039 | 0:65f1469d6bfb | 63 | * @param r_pn The return value of x op y |
va009039 | 0:65f1469d6bfb | 64 | * @param op The operator (+,-,*,/ and power) |
va009039 | 0:65f1469d6bfb | 65 | * @return Return status |
va009039 | 0:65f1469d6bfb | 66 | */ |
va009039 | 0:65f1469d6bfb | 67 | PmReturn_t float_op(pPmObj_t px, pPmObj_t py, pPmObj_t *r_pn, int8_t op); |
va009039 | 0:65f1469d6bfb | 68 | |
va009039 | 0:65f1469d6bfb | 69 | /** |
va009039 | 0:65f1469d6bfb | 70 | * Returns by reference a boolean that is x op y. |
va009039 | 0:65f1469d6bfb | 71 | * |
va009039 | 0:65f1469d6bfb | 72 | * @param px The float left-hand argument |
va009039 | 0:65f1469d6bfb | 73 | * @param py The float right-hand argument |
va009039 | 0:65f1469d6bfb | 74 | * @param r_pn The return value of x cmp y |
va009039 | 0:65f1469d6bfb | 75 | * @param cmp The comparison operator |
va009039 | 0:65f1469d6bfb | 76 | * @return Return status |
va009039 | 0:65f1469d6bfb | 77 | */ |
va009039 | 0:65f1469d6bfb | 78 | PmReturn_t float_compare(pPmObj_t px, pPmObj_t py, pPmObj_t *r_pobj, |
va009039 | 0:65f1469d6bfb | 79 | PmCompare_t cmp); |
va009039 | 0:65f1469d6bfb | 80 | |
va009039 | 0:65f1469d6bfb | 81 | #ifdef HAVE_PRINT |
va009039 | 0:65f1469d6bfb | 82 | /** |
va009039 | 0:65f1469d6bfb | 83 | * Sends out a float object. |
va009039 | 0:65f1469d6bfb | 84 | * The number is preceded with a "-" when necessary. |
va009039 | 0:65f1469d6bfb | 85 | * |
va009039 | 0:65f1469d6bfb | 86 | * @param pObj Ptr to float object |
va009039 | 0:65f1469d6bfb | 87 | * @return Return status |
va009039 | 0:65f1469d6bfb | 88 | */ |
va009039 | 0:65f1469d6bfb | 89 | PmReturn_t float_print(pPmObj_t pf); |
va009039 | 0:65f1469d6bfb | 90 | |
va009039 | 0:65f1469d6bfb | 91 | #endif /* HAVE_PRINT */ |
va009039 | 0:65f1469d6bfb | 92 | |
va009039 | 0:65f1469d6bfb | 93 | #endif /* HAVE_FLOAT */ |
va009039 | 0:65f1469d6bfb | 94 | |
va009039 | 0:65f1469d6bfb | 95 | #endif /* __FLOAT_H__ */ |