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

Subversion Repositories scarts

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
#define LINT_MIN (0x80000000)
2
#define LINT_MAXp1_F 0x1p32f
3
#define LINT_WIDTH 32
4
 
5
#define LLINT_MAXp1_F 0x1p64f
6
 
7
double __floatdidf (long long u);
8
float __floatdisf (long long u);
9
unsigned long __fixunssfsi (float a);
10
unsigned long __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 = (long)(u >> LINT_WIDTH);
19
  d *= LINT_MAXp1_F;
20
  d += (unsigned long) u;
21
  return d;
22
}
23
 
24
float __floatdisf (long long u)
25
{
26
  double d = (long)(u >> LINT_WIDTH);
27
  d *= LINT_MAXp1_F;
28
  d += (unsigned long) u;
29
  return (float) d;
30
}
31
 
32
unsigned long __fixunssfsi (float a)
33
{
34
  if (a >= (float) (unsigned long) LINT_MIN)
35
    return (long) (a - (unsigned long) LINT_MIN) + (unsigned long) LINT_MIN;
36
  return (long) a;
37
}
38
 
39
unsigned long __fixunsdfsi (double a)
40
{
41
  if ( a >= (double) (unsigned long) LINT_MIN )
42
    return (long) (a - (unsigned long) LINT_MIN) + (unsigned long) LINT_MIN;
43
  return (long) 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 long hi = d / LINT_MAXp1_F;
57
  unsigned long lo = d - (double) hi * LINT_MAXp1_F;
58
  return ((unsigned long long) hi << LINT_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 long hi = a / LINT_MAXp1_F;
71
  unsigned long lo = a - (double) hi * LINT_MAXp1_F;
72
  return ((unsigned long long) hi << LINT_WIDTH) | lo;
73
}

powered by: WebSVN 2.1.0

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