Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
Loading...
Searching...
No Matches
AuxConvert.c
Go to the documentation of this file.
1
13#include "fasp.h"
14#include "fasp_functs.h"
15
16/*---------------------------------*/
17/*-- Public Functions --*/
18/*---------------------------------*/
19
32unsigned long fasp_aux_change_endian4 (const unsigned long x)
33{
34 unsigned char *ptr = (unsigned char *)&x;
35 return (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
36}
37
50double fasp_aux_change_endian8 (const double x)
51{
52 double dbl;
53 unsigned char *bytes, *buffer;
54
55 buffer=(unsigned char *)&dbl;
56 bytes=(unsigned char *)&x;
57
58 buffer[0]=bytes[7];
59 buffer[1]=bytes[6];
60 buffer[2]=bytes[5];
61 buffer[3]=bytes[4];
62 buffer[4]=bytes[3];
63 buffer[5]=bytes[2];
64 buffer[6]=bytes[1];
65 buffer[7]=bytes[0];
66 return dbl;
67}
68
81double fasp_aux_bbyteToldouble (const unsigned char bytes[])
82{
83 double dbl;
84 unsigned char *buffer;
85 buffer=(unsigned char *)&dbl;
86 buffer[0]=bytes[7];
87 buffer[1]=bytes[6];
88 buffer[2]=bytes[5];
89 buffer[3]=bytes[4];
90 buffer[4]=bytes[3];
91 buffer[5]=bytes[2];
92 buffer[6]=bytes[1];
93 buffer[7]=bytes[0];
94 return dbl;
95}
96
97/*---------------------------------*/
98/*-- End of File --*/
99/*---------------------------------*/
unsigned long fasp_aux_change_endian4(const unsigned long x)
Swap order for different endian systems.
Definition: AuxConvert.c:32
double fasp_aux_bbyteToldouble(const unsigned char bytes[])
Swap order of double-precision float for different endian systems.
Definition: AuxConvert.c:81
double fasp_aux_change_endian8(const double x)
Swap order for different endian systems.
Definition: AuxConvert.c:50
Main header file for the FASP project.