⚲
Projet
Général
Profil
Connexion
S'enregistrer
Accueil
Projets
Aide
Recherche
:
Polytech Ge Sous Traitance
Tous les projets
Polytech Projets Ge
»
Polytech Ge Sous Traitance
Aperçu
Activité
Roadmap
Demandes
Gantt
Calendrier
Annonces
Documents
Wiki
Fichiers
Dépôt
Télécharger (894 octets)
Bug #14829
» Conversion_float32_uint16.c
Ramazan CELIK
, 02/12/2022 19:07
#include
<stdio.h>
#include
<stdlib.h>
#include
<math.h>
/**Prototype declaration**/
int
convertion
(
float
x
,
float
min
,
float
max
);
void
main
(){
int
val
;
val
=
convertion
(
2
.
8
,
0
.
0
,
5
.
0
);
printf
(
"val : %i"
,
val
);
}
int
convertion
(
float
x
,
float
min
,
float
max
)
{
int
val_int
=
1
;
int
somme
=
0
;
int
p
=
2
;
if
(
min
<
0
){
x
=
x
+
(
-
1
*
min
);
max
=
max
+
(
-
1
*
min
);
min
=
0
;
for
(
int
i
=
1
;
i
<
17
;
i
++
){
val_int
*=
p
;
}
somme
=
(
int
)((
x
*
(
val_int
-
1
))
/
(
max
-
min
));
}
else
if
(
min
>
0
){
x
=
x
-
min
;
max
=
max
-
min
;
min
=
0
;
for
(
int
i
=
1
;
i
<
17
;
i
++
){
val_int
*=
p
;
}
somme
=
(
int
)((
x
*
(
val_int
-
1
))
/
(
max
-
min
));
}
else
{
for
(
int
i
=
1
;
i
<
17
;
i
++
){
val_int
*=
p
;
}
somme
=
(
int
)((
x
*
(
val_int
-
1
))
/
(
max
-
min
));
}
return
somme
;
}
« Précédent
1
2
Suivant »
(2-2/2)
Chargement...