OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [config/] [scarts32/] [fixfloat.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
#define INT_MIN (0x80000000)
2
#define INT_MAXp1_F 0x1p32f
3
#define INT_WIDTH 32
4
 
5
#define LLINT_MAXp1_F 0x1p64f
6
 
7
double __floatdidf (long long u);
8
float __floatdisf (long long u);
9
unsigned int __fixunssfsi (float a);
10
unsigned int __fixunsdfsi (double a);
11
long long __fixsfdi (float a);
12
long long __fixunssfdi (float a);
13
long long __fixdfdi (double a);
14
long long __fixunsdfdi (double a);
15
 
16
double __floatdidf (long long u)
17
{
18
  double d = (int)(u >> INT_WIDTH);
19
  d *= INT_MAXp1_F;
20
  d += (unsigned int) u;
21
  return d;
22
}
23
 
24
float __floatdisf (long long u)
25
{
26
  double d = (int)(u >> INT_WIDTH);
27
  d *= INT_MAXp1_F;
28
  d += (unsigned int) u;
29
  return (float) d;
30
}
31
 
32
unsigned int __fixunssfsi (float a)
33
{
34
  if (a >= (float) (unsigned int) INT_MIN)
35
    return (int) (a - (unsigned int) INT_MIN) + (unsigned int) INT_MIN;
36
  return (int) a;
37
}
38
 
39
unsigned int __fixunsdfsi (double a)
40
{
41
  if ( a >= (double) (unsigned int) INT_MIN )
42
    return (int) (a - (unsigned int) INT_MIN) + (unsigned int) INT_MIN;
43
  return (int) a;
44
}
45
 
46
long long __fixsfdi (float a)
47
{
48
  if (a < 0)
49
    return - __fixunssfdi (-a);
50
  return __fixunssfdi (a);
51
}
52
 
53
long long __fixunssfdi (float a)
54
{
55
  double d = a;
56
  unsigned int hi = d / INT_MAXp1_F;
57
  unsigned long lo = d - (double) hi * INT_MAXp1_F;
58
  return ((unsigned long long) hi << INT_WIDTH) | lo;
59
}
60
 
61
long long __fixdfdi (double a)
62
{
63
  if (a < 0)
64
    return - __fixunsdfdi (-a);
65
  return __fixunsdfdi (a);
66
}
67
 
68
long long __fixunsdfdi (double a)
69
{
70
  unsigned int hi = a / INT_MAXp1_F;
71
  unsigned int lo = a - (double) hi * INT_MAXp1_F;
72
  return ((unsigned long long) hi << INT_WIDTH) | lo;
73
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.