Skip to content

Commit b83289b

Browse files
committed
Create CommonMath.cpp
1 parent 389b9b8 commit b83289b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

core-implement/CommonMath.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
// This file is subject to the terms and conditions defined in
3+
// file 'LICENSE.md', which is part of this source code package.
4+
*/
5+
6+
#include "mbed.h"
7+
8+
#define PinMode Arduino_PinMode
9+
#include "core-api/api/Common.h"
10+
#undef PinMode
11+
12+
// WMath prototypes
13+
long random(long upper){
14+
if(upper == 0){ return 0; }
15+
return random(0, upper);
16+
}
17+
18+
long random(long lower, long upper){
19+
long diff = upper - lower;
20+
return rand() % diff + lower;
21+
}
22+
23+
void randomSeed(unsigned long seed){
24+
if ( seed != 0 ){
25+
srand( seed ) ;
26+
}
27+
}

0 commit comments

Comments
 (0)