Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_tlsv12/sys/src/cmd/unix/drawterm/libmp/mptoui.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "os.h"
2
#include <mp.h>
3
#include "dat.h"
4
 
5
/*
6
 *  this code assumes that mpdigit is at least as
7
 *  big as an int.
8
 */
9
 
10
mpint*
11
uitomp(uint i, mpint *b)
12
{
13
	if(b == nil)
14
		b = mpnew(0);
15
	mpassign(mpzero, b);
16
	if(i != 0)
17
		b->top = 1;
18
	*b->p = i;
19
	return b;
20
}
21
 
22
uint
23
mptoui(mpint *b)
24
{
25
	uint x;
26
 
27
	x = *b->p;
28
	if(b->sign < 0){
29
		x = 0;
30
	} else {
31
		if(b->top > 1 || x > MAXUINT)
32
			x =  MAXUINT;
33
	}
34
	return x;
35
}