Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/structures/Constants.sac
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,3 @@ external double maxdouble();
external double epidouble();
#pragma linksign[0]
#pragma linkobj "src/Constants/epidouble.o"

external int randmax();
#pragma linksign[0]
#pragma linkobj "src/Constants/randmax.o"
5 changes: 3 additions & 2 deletions src/structures/src/Char/ctype.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* They may return any non-zero value when true, but a SAC bool is true if 1.
*/

#include <sacinterface.h>
#include <ctype.h>

typedef unsigned char uchar;
Expand Down Expand Up @@ -68,12 +69,12 @@ int SACiscntrl(uchar c)
return iscntrl(c) != 0;
}

int SACisascii(int c)
int SACisascii(sac_int c)
{
return c >= 0 && c < 256 && isascii(c) != 0;
}

int SACtoascii(int c)
int SACtoascii(sac_int c)
{
return toascii(c & 0xFF);
}
Expand Down
14 changes: 11 additions & 3 deletions src/structures/src/Constants/maxint.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#include <limits.h>
#include <sacinterface.h>

#include <stdint.h>

int maxint( void)
sac_int maxint( void)
{
return( INT_MAX);
sac_int num_bits = 8 * sizeof(sac_int);
/**
* To avoid overflow:
* 2^(num_bits - 1) - 1 = 2 * 2^(num_bits - 2) - 1 =
* 2^(num_bits - 2) + (2^(num_bits - 2) - 1)
**/
sac_int half = (sac_int)1 << (num_bits - 2);
return half + (half - 1);
}
7 changes: 4 additions & 3 deletions src/structures/src/Constants/minint.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <sacinterface.h>
#include <limits.h>


int minint( void)
sac_int minint( void)
{
return( INT_MIN );
sac_int num_bits = 8 * sizeof(sac_int);
return -((sac_int)1 << (num_bits - 1));
}