% Load required packages for floating point calculations and key-value options
\RequirePackage{fp}
\RequirePackage{xkeyval}
\AtBeginDocument{\renewcommand{\labelitemi}{\textbullet}}


% sgn:int:sep:frc:exp:sgx:pow



\def\multiSymbole{}



% === Flag and variable initialization ===
\newif\ifAMCX@verbose\AMCX@verbosefalse

\newif\ifAMCX@INisNORM%

\def\AMCX@INsgn{}%
\def\AMCX@INint{}%
\def\AMCX@INfrc{}%
\def\AMCX@INpow{}%
\def\AMCX@INsgx{}%
\def\AMCX@SCIsgn{}%
\def\AMCX@SCIint{}%
\def\AMCX@SCIfrc{}%
\def\AMCX@SCIpow{}%
\def\AMCX@SCIsgx{}%

\newcounter{AMCX@SCIfrcDigits}
\newcounter{AMCX@SCIpowDigits}
\newcounter{AMCX@NORMintDigits}
\newcounter{AMCX@NORMfrcDigits}

\newif\ifAMCX@INsgnEnabled
\newif\ifAMCX@INintEnabled
\newif\ifAMCX@INfrcEnabled
\newif\ifAMCX@INsgxEnabled
\newif\ifAMCX@INpowEnabled
\newif\ifAMCX@INvalidSymbol
\newif\ifAMCX@INvalid

\newif\ifAMCX@INsgnExplicit
\newif\ifAMCX@INintExplicit
\newif\ifAMCX@INsepExplicit
\newif\ifAMCX@INfrcExplicit
\newif\ifAMCX@INexpExplicit
\newif\ifAMCX@INsgxExplicit
\newif\ifAMCX@INpowExplicit

\newcounter{AMCX@INintDigits}
\newcounter{AMCX@INfrcDigits}
\newcounter{AMCX@INpowDigits}

\newcounter{AMCX@garbCount}


\newif\ifAMCX@symbolIsNumber
\newif\ifAMCX@symbolIsSign
\newif\ifAMCX@symbolIsDecimalSep
\newif\ifAMCX@symbolIsExponentMarker

\newif\ifAMCX@displayFormatinput
\newif\ifAMCX@displayFormatsci
\newif\ifAMCX@displayFormatnorm

\newif\ifAMCX@forceSign
\newif\ifAMCX@forceSignExp
\define@boolkey{AMCX}{groupExp}[false]{}% creates \ifKV@AMCX@groupExp
\define@boolkey{AMCX}{groupInt}[false]{}% creates \ifKV@AMCX@groupInt
\define@key{AMCX}{powRange}{\AMCX@setPowRange#1}
\define@key{AMCX}{frcRange}{\AMCX@setFrcRange#1}
\define@key{AMCX}{intRange}{\AMCX@setIntRange#1}
\define@key{AMCX}{display}{\expandafter\AMCX@analyseOutDisplay#1\null}
\define@key{AMCX}{lines}{\edef\AMCX@keyboardLines{#1}}

\define@key{PERL}{delta}[0]{\AMCX@PERL@delta{#1}}
\define@key{PERL}{points}[1]{\AMCX@PERL@points{#1}}

\def\AMCX@decimalSepDisplay{\hskip-0.3em\scalebox{2}{,}\hskip-0.2em}
\def\AMCX@tenPowerDisplay{\scalebox{1.5}{$\times\!\!10\hskip0.3em\widehat{}$}\hskip0.5em}

\newcount\AMCX@reponse%
\newcount\AMCX@ligne%



% === Initialization of parsing state and display configuration ===
\def\AMCX@initialize#1{%
	\AMCX@INisNORMtrue%
	%
	\AMCX@INsgnEnabledtrue%
	\AMCX@INintEnabledtrue%
	\AMCX@INfrcEnabledfalse%
	\AMCX@INsgxEnabledfalse%
	\AMCX@INpowEnabledfalse%
	%
	\AMCX@INsgnExplicitfalse%
	\AMCX@INintExplicitfalse%
	\AMCX@INsepExplicitfalse%
	\AMCX@INfrcExplicitfalse%
	\AMCX@INexpExplicitfalse%
	\AMCX@INsgxExplicitfalse%
	\AMCX@INpowExplicitfalse%
	%
	\AMCX@INvalidfalse%
	%
	\AMCX@displayFormatinputfalse
	\AMCX@displayFormatscifalse
	\AMCX@displayFormatnormfalse
	%	
	\def\AMCX@INsgn{}%
	\def\AMCX@INint{}%
	\def\AMCX@INfrc{}%
	\def\AMCX@INpow{}%
	\def\AMCX@INsgx{}%
	%
	\def\AMCX@SCIsgn{}%
	\def\AMCX@SCIint{}%
	\def\AMCX@SCIfrc{}%
	\def\AMCX@SCIpow{}%
	\def\AMCX@SCIsgx{}%
	\def\AMCX@SCIpowRangeMin{1}
	\def\AMCX@SCIpowRangeMax{9}
	\def\AMCX@SCIfrcRangeMin{1}
	\def\AMCX@SCIfrcRangeMax{9}
	%
	\def\AMCX@NORMsgn{}%
	\def\AMCX@NORMint{}%
	\def\AMCX@NORMfrc{}%
	\def\AMCX@NORMintRangeMin{1}
	\def\AMCX@NORMintRangeMax{9}
	\def\AMCX@NORMfrcRangeMin{1}
	\def\AMCX@NORMfrcRangeMax{9}
	%
	\setcounter{AMCX@SCIfrcDigits}{2}%
	\setcounter{AMCX@SCIpowDigits}{1}%
	\setcounter{AMCX@NORMintDigits}{2}%
	\setcounter{AMCX@NORMfrcDigits}{3}%
	%
	\def\AMCX@keyboardLines{3}%
	%
	\setkeys{AMCX}{#1}%
	\ifKV@AMCX@groupInt\setcounter{AMCX@NORMintDigits}{1}\fi % Évite un bug survenant sur le calcul
															 % de ANS lorsque intDigits > 1
	\ifKV@AMCX@groupExp\setcounter{AMCX@SCIpowDigits}{1}\fi  % Évite un bug survenant sur le calcul
															 % de ANS lorsque powDigits > 1
}



% === Add a single character to the parsed number ===
\def\AMCX@addSymbolToInputNumber#1{%
	\ifAMCX@verbose\par* #1 * \fi
	\AMCX@INvalidSymbolfalse%
	\ifAMCX@INsgnEnabled\ifAMCX@symbolIsSign%
		\edef\AMCX@INsgn{#1}%
		\AMCX@INsgnEnabledfalse%	le signe n'est plus modifiable
		\ifAMCX@verbose saved as sign\fi%
		\AMCX@INvalidSymboltrue%
		\AMCX@INsgnExplicittrue%
	\fi\fi
	\ifAMCX@INintEnabled\ifAMCX@symbolIsNumber%
		\edef\AMCX@xx{\AMCX@INint}%
		\edef\AMCX@INint{\AMCX@xx#1}% on concatène le nouveau caractère avec ce qui existe déjà
		\AMCX@INsgnEnabledfalse% le signe n'est plus modifiable
		\ifAMCX@verbose added to integral part\fi%
		\AMCX@INvalidSymboltrue%
		\AMCX@INintExplicittrue%
		\stepcounter{AMCX@INintDigits}%
	\fi\fi
	\ifAMCX@INintEnabled\ifAMCX@symbolIsDecimalSep%
		\AMCX@INsgnEnabledfalse% le signe n'est plus modifiable
		\AMCX@INintEnabledfalse% la partie entière n'est plus modifiable
		\AMCX@INfrcEnabledtrue% la partie décimale devient modifiable
		\ifAMCX@verbose saved as decimal marker\fi%
		\AMCX@INvalidSymboltrue%
		\AMCX@INsepExplicittrue%
	\fi\fi
	\ifAMCX@INfrcEnabled\ifAMCX@symbolIsNumber%
		\edef\AMCX@xx{\AMCX@INfrc}%
		\edef\AMCX@INfrc{\AMCX@xx#1}% on concatène le nouveau caractère avec ce qui existe déjà
		\ifAMCX@verbose added to fractionnal part\fi%
		\AMCX@INvalidSymboltrue%
		\AMCX@INfrcExplicittrue%
		\stepcounter{AMCX@INfrcDigits}%
	\fi\fi
	\ifAMCX@INpowEnabled\else\ifAMCX@symbolIsExponentMarker%
		\AMCX@INsgnEnabledfalse% le signe n'est plus modifiable
		\AMCX@INintEnabledfalse% la partie entière n'est plus modifiable
		\AMCX@INfrcEnabledfalse% la partie décimale n'est plus modifiable
		\AMCX@INsgxEnabledtrue%  le signe de l'exposant devient modifiable
		\AMCX@INpowEnabledtrue%  la valeur de l'exposant devient modifiable
		\ifAMCX@verbose saved as exponent marker\fi%
		\AMCX@INvalidSymboltrue%
		\AMCX@INexpExplicittrue%
		\AMCX@INisNORMfalse
	\fi\fi
	\ifAMCX@INsgxEnabled\ifAMCX@symbolIsSign%
		\edef\AMCX@INsgx{#1}%
		\AMCX@INsgxEnabledfalse%  le signe de l'exposant n'est plus modifiable
		\ifAMCX@verbose saved as power sign\fi%
		\AMCX@INvalidSymboltrue%
		\AMCX@INsgxExplicittrue%
	\fi\fi	
	\ifAMCX@INpowEnabled\ifAMCX@symbolIsNumber%
		\edef\AMCX@xx{\AMCX@INpow}%
		\edef\AMCX@INpow{\AMCX@xx#1}%% on concatène le nouveau caractère avec ce qui existe déjà
		\AMCX@INsgxEnabledfalse%  le signe de l'exposant n'est plus modifiable
		\ifAMCX@verbose added to power\fi%
		\AMCX@INvalidSymboltrue%
		\AMCX@INpowExplicittrue%
		\stepcounter{AMCX@INpowDigits}%
	\fi\fi
	\unless\ifAMCX@INvalidSymbol\par Fatal error:%
		 Invalid symbol [#1]!\par Aborting.\fi%
}



% === Analyze character type (digit, sign, separator, exponent) ===
\def\AMCX@nalyseSymbol#1{%
	\AMCX@symbolIsNumberfalse%
	\AMCX@symbolIsSignfalse%
	\AMCX@symbolIsDecimalSepfalse%
	\AMCX@symbolIsExponentMarkerfalse%
	\ifcat1\expandafter\noexpand#1
		\ifnum\expandafter`#1>47
			\ifnum\expandafter`#1<58
				\AMCX@symbolIsNumbertrue%
			\fi%
		\fi%
	\fi%
	\if#1E\AMCX@symbolIsExponentMarkertrue\fi
	\if#1e\AMCX@symbolIsExponentMarkertrue\fi
	\if#1,\AMCX@symbolIsDecimalSeptrue\fi
	\if#1.\AMCX@symbolIsDecimalSeptrue\fi
	\if#1+\AMCX@symbolIsSigntrue\fi
	\if#1-\AMCX@symbolIsSigntrue\fi
}



% === Convert parsed input to scientific notation ===
\def\AMCX@toSciForm{%
	% Mise sous la forme scientifique (obtention de la bonne puissance de 10)
	\setcounter{AMCX@garbCount}{\AMCX@INsgx\AMCX@INpow}%
	\FPeval{\AMCX@garbi}{round((\AMCX@INint.\AMCX@INfrc),15)}%
	\def\AMCX@getSCIintfrc##1.##2\null{\edef\AMCX@SCIint{##1}\edef\AMCX@SCIfrc{##2}}%
	\ifnum\AMCX@INint>9%
		\loop%
		\FPeval{\AMCX@garbi}{round(\AMCX@garbi/10,15)}%
		\stepcounter{AMCX@garbCount}%
		\expandafter\AMCX@getSCIintfrc\AMCX@garbi\null%
		\ifnum\AMCX@SCIint>9\repeat%
	\else\ifnum\AMCX@INint<1%
		\loop%
		\FPeval{\AMCX@garbi}{round(\AMCX@garbi*10,15)}%
		\addtocounter{AMCX@garbCount}{-1}%
		\expandafter\AMCX@getSCIintfrc\AMCX@garbi\null%
		\ifnum\AMCX@SCIint=0\repeat%
	\fi\fi%
	\FPeval{\AMCX@garbi}{round(\AMCX@garbi,\theAMCX@SCIfrcDigits)}%
	\expandafter\AMCX@getSCIintfrc\AMCX@garbi\null%
	% Traitement du signe de la mantisse (forcé ou non)
	\if-\AMCX@INsgn%
		\def\AMCX@SCIsgn{-}%
	\else\ifAMCX@forceSign
		\def\AMCX@SCIsgn{+}%
	\fi\fi%
	% Traitement du signe de l'exposant (forcé ou non)
	\ifnum\theAMCX@garbCount<0%
		\setcounter{AMCX@garbCount}{-\theAMCX@garbCount}%
		\def\AMCX@SCIsgx{-}%
	\else\ifAMCX@forceSignExp
		\def\AMCX@SCIsgx{+}%
	\fi\fi%
	% Mise en forme de l'exposant (ajout de "leading zeros" si besoin)
	\edef\AMCX@SCIpow{\theAMCX@garbCount}
	\def\AMCX@getSCIpow##1.##2\null{\ifnum##1=0\edef\AMCX@SCIpow{##2}\else\edef\AMCX@SCIpow{##1##2}\fi}
	\FPeval{\AMCX@SCIpow}{round(\AMCX@SCIpow/(10^\theAMCX@SCIpowDigits),\theAMCX@SCIpowDigits)}
	\expandafter\AMCX@getSCIpow\AMCX@SCIpow\null%
	\scoring{set.ANS=\AMCX@SCIsgn\AMCX@SCIint.\AMCX@SCIfrc*10**(\AMCX@SCIsgx\AMCX@SCIpow)}%	
	%\quad SCI \ = \AMCX@SCIsgn\AMCX@SCIint.\AMCX@SCIfrc E\AMCX@SCIsgx\AMCX@SCIpow
}



% === Convert parsed input to normal decimal notation ===
\def\AMCX@toNormForm{%
	% Construction du nombre sous forme "NORM" (puissance de 10 éventuelle intégrée)
	\FPeval{\AMCX@garbi}{round((\AMCX@INint.\AMCX@INfrc*10^(\AMCX@INsgx\AMCX@INpow)),%
												 \theAMCX@NORMfrcDigits)}%
	% Extraction des parties entiere et decimale
	\def\AMCX@getNORMintfrc##1.##2\null{\edef\AMCX@NORMint{##1}\edef\AMCX@NORMfrc{##2}}%
	\expandafter\AMCX@getNORMintfrc\AMCX@garbi\null%
	% Mise en forme de la partie entière (ajout de "leading zeros" si besoin)
	\def\AMCX@getNORMint##1.##2\null{\ifnum##1=0\edef\AMCX@NORMint{##2}\else\edef\AMCX@NORMint{##1##2}\fi}
	\FPeval{\AMCX@NORMint}{round(\AMCX@NORMint/(10^\theAMCX@NORMintDigits),\theAMCX@NORMintDigits)}
	\expandafter\AMCX@getNORMint\AMCX@NORMint\null%
	% Traitement du signe (forcé ou non):
	\if-\AMCX@INsgn%
		\edef\AMCX@NORMsgn{-}%
	\else\ifAMCX@forceSign
		\edef\AMCX@NORMsgn{+}%
	\fi\fi%
	\scoring{set.ANS=\AMCX@NORMsgn\AMCX@NORMint.\AMCX@NORMfrc}%
	%\quad NORM = \AMCX@NORMsgn\AMCX@NORMint.\AMCX@NORMfrc
}



% === Build full number by iterating over input string ===
\def\AMCX@buildInputNumber#1{%
	\@tfor\tmp:=#1\do{%		
	\expandafter\AMCX@nalyseSymbol\tmp%
	\AMCX@addSymbolToInputNumber\tmp
	\ifAMCX@INvalidSymbol\else\@break@tfor\fi}%
	\ifAMCX@INvalidSymbol%
		\ifx\AMCX@INint\empty\def\AMCX@INint{0}\fi
		\ifx\AMCX@INfrc\empty\def\AMCX@INfrc{0}\fi
		\ifx\AMCX@INpow\empty\def\AMCX@INpow{0}\fi
		\AMCX@INvalidtrue
	\fi
}


\def\AMCX@setIntRange(#1-#2){
	\edef\AMCX@NORMintRangeMin{#1}
	\edef\AMCX@NORMintRangeMax{#2}
}

\def\AMCX@setPowRange(#1-#2){
	\edef\AMCX@SCIpowRangeMin{#1}
	\edef\AMCX@SCIpowRangeMax{#2}
}

\def\AMCX@setFrcRange(#1-#2){
	\edef\AMCX@NORMfrcRangeMin{#1}
	\edef\AMCX@NORMfrcRangeMax{#2}
	\edef\AMCX@SCIfrcRangeMin{#1}
	\edef\AMCX@SCIfrcRangeMax{#2}
}


\def\AMCX@analyseOutDisplay#1(#2.#3)#4\null{
	\def\tmp@sgn{#1}
	\def\tmp@int{#2}
	\def\tmp@@frc{#3}
	\def\tmp@exp{#4}
	\ifx\tmp@sgn\empty\AMCX@forceSignfalse\else\AMCX@forceSigntrue\fi
	\ifx\tmp@exp\empty%
		\AMCX@displayFormatnormtrue
		\ifx\tmp@int\empty\setcounter{AMCX@NORMintDigits}{0}\else\setcounter{AMCX@NORMintDigits}{#2}\fi
		\ifx\tmp@frc\empty\setcounter{AMCX@NORMfrcDigits}{0}\else\setcounter{AMCX@NORMfrcDigits}{#3}\fi
	\else
		\AMCX@displayFormatscitrue
		\ifx\tmp@frc\empty\setcounter{AMCX@SCIfrcDigits}{0}\else\setcounter{AMCX@SCIfrcDigits}{#3}\fi
		\expandafter\AMCX@analyseOutDisplayExp\expandafter\null#4\null%
	\fi
}
\def\AMCX@analyseOutDisplayExp\null E#1(#2)\null{
	\def\tmp@sgx{#1}
	\def\tmp@pow{#2}
	\ifx\tmp@sgx\empty\AMCX@forceSignExpfalse\else\AMCX@forceSignExptrue\fi
	\ifx\tmp@pow\empty\setcounter{AMCX@SCIpowDigits}{1}\else\setcounter{AMCX@SCIpowDigits}{#2}\fi
}



% === Generate numeric multiple choice options ===
\def\AMCX@numChoices#1#2#3#4#5{%#1:MIN  #2:MAX  #3:LINES  #4:NUM
	\AMCX@reponse #1\relax%
	\advance\AMCX@reponse \m@ne%
	\fboxrule=1.2pt%
	\fcolorbox{lightgray}{white}{%
	\loop%
		\AMCX@ligne 0\relax%
		\ifnum\AMCX@reponse<#1\hskip.8em\else{\color{lightgray}\vline}\hskip1.2em\fi%
		{\begin{minipage}{1.5em}%
		\loop%
			\advance\AMCX@ligne \@ne%
			\global\advance\AMCX@reponse \@ne%
			\ifnum\AMCX@reponse>#2\linebreak\phantom{.}%
			\else\ifnum\AMCX@reponse=#4\correctchoice\else\wrongchoice\fi{\color{gray}\the\AMCX@reponse}%
			\scoring{set.#5=\the\AMCX@reponse}%
			\fi%
			\ifnum\AMCX@ligne<#3%
		\repeat%
		\end{minipage}}%
	\ifnum\AMCX@reponse<#2%
	\repeat\hskip-.3em}%
	\hskip.1em%
}




% === Generate sign choice box (+ or -) ===
\def\AMCX@signChoices#1#2{%
	\strut%
	\setlength{\fboxrule}{1.2pt}%
	\fcolorbox{lightgray}{white}{\hskip0.8em%
	\begin{minipage}{6mm}%
		\if-#1\correctchoice\else\wrongchoice\fi{\color{gray}$-$}%
		\scoring{set.#2=-1}%
	\end{minipage}%
	\hskip-.5em}%
	\hskip.1em%
}



% === Display a numeric keyboard for answer input ===
\def\AMCX@displayKeyboard{%
	\choices[o]\tt\strut\hskip-1cm
	\ifAMCX@displayFormatnorm
		\unless\if\AMCX@NORMsgn\@empty\AMCX@signChoices{\AMCX@NORMsgn}{SGN}\fi%
		\ifKV@AMCX@groupInt%
			\AMCX@numChoices{\AMCX@NORMintRangeMin}{\AMCX@NORMintRangeMax}{\AMCX@keyboardLines}{\AMCX@NORMint}{INT0}%
		\else%
			\setcounter{AMCX@garbCount}{0}%
			\expandafter\@tfor\expandafter\tmp\expandafter:\expandafter=\AMCX@NORMint\do{%
				\stepcounter{AMCX@garbCount}}%
			\expandafter\@tfor\expandafter\tmp\expandafter:\expandafter=\AMCX@NORMint\do{%	
				\addtocounter{AMCX@garbCount}{-1}%
				\AMCX@numChoices{\AMCX@NORMintRangeMin}{\AMCX@NORMintRangeMax}{\AMCX@keyboardLines}{\tmp}{INT\theAMCX@garbCount}}%
		\fi%
		\AMCX@decimalSepDisplay%
		\setcounter{AMCX@garbCount}{0}%
		\expandafter\@tfor\expandafter\tmp\expandafter:\expandafter=\AMCX@NORMfrc\do{%
			\AMCX@numChoices{\AMCX@NORMfrcRangeMin}{\AMCX@NORMfrcRangeMax}{\AMCX@keyboardLines}{\tmp}{FRC\theAMCX@garbCount}%
			\stepcounter{AMCX@garbCount}}%
	\fi%
	%
	\ifAMCX@displayFormatsci
		\unless\if\AMCX@SCIsgn\@empty\AMCX@signChoices{\AMCX@SCIsgn}{SGN}\fi%
		\AMCX@numChoices{1}{9}{\AMCX@keyboardLines}{\AMCX@SCIint}{INT0}%
		\AMCX@decimalSepDisplay%
		\setcounter{AMCX@garbCount}{0}%
		\expandafter\@tfor\expandafter\tmp\expandafter:\expandafter=\AMCX@SCIfrc\do{%		
			\AMCX@numChoices{\AMCX@SCIfrcRangeMin}{\AMCX@SCIfrcRangeMax}{\AMCX@keyboardLines}{\tmp}{FRC\theAMCX@garbCount}%
			\stepcounter{AMCX@garbCount}}%
		\AMCX@tenPowerDisplay%
		\unless\if\AMCX@SCIsgx\@empty\AMCX@signChoices{\AMCX@SCIsgx}{SGX}\fi
		\ifKV@AMCX@groupExp%
			\AMCX@numChoices{\AMCX@SCIpowRangeMin}{\AMCX@SCIpowRangeMax}{\AMCX@keyboardLines}{\AMCX@SCIpow}{POW0}%
		\else%
		\setcounter{AMCX@garbCount}{0}%
		\expandafter\@tfor\expandafter\tmp\expandafter:\expandafter=\AMCX@SCIpow\do{%
			\stepcounter{AMCX@garbCount}}%
		\expandafter\@tfor\expandafter\tmp\expandafter:\expandafter=\AMCX@SCIpow\do{%
			\addtocounter{AMCX@garbCount}{-1}%	
			\AMCX@numChoices{\AMCX@SCIpowRangeMin}{\AMCX@SCIpowRangeMax}{\AMCX@keyboardLines}{\tmp}{POW\theAMCX@garbCount}}%
	\fi
	\fi
	\endchoices
}




% === Main user command to parse a number and setup keyboard & scoring ===
\newcommand{\parseNumber}[2][]{%
	\expandafter\AMCX@initialize\expandafter{#1}%
	\expandafter\AMCX@buildInputNumber\expandafter{#2}%
	\ifAMCX@INvalid
		\ifAMCX@displayFormatsci \AMCX@toSciForm\fi
		\ifAMCX@displayFormatnorm \AMCX@toNormForm\fi
	\fi
	%\AMC@correctrue%
	\AMCX@setScoring%
	\AMCX@displayKeyboard%
	\vskip2ex
}


\newcommand{\setScoring}[1]{
	\def\PERL@points{1}
	\def\PERL@delta{0}
	\setkeys{PERL}{#1}%
}
\def\AMCX@PERL@points#1{%
	\def\PERL@points{#1}
	%\quad PTS = #1
}
\def\AMCX@PERL@delta#1{%
	\def\PERL@delta{#1}
	%\quad DELTA = #1
}




\def\AMCX@setScoring{%
	\ifAMCX@displayFormatnorm%
		\scoring{set.DELTA=\PERL@delta/10**(\theAMCX@NORMfrcDigits)}%
	\fi%
	\ifAMCX@displayFormatsci%\AMCX@SCIsgx\AMCX@SCIpow
		\scoring{set.DELTA=\PERL@delta*10**((\AMCX@SCIsgx\AMCX@SCIpow)-(\theAMCX@SCIfrcDigits))}%
	\fi	
	\scoring{set.PTS=\PERL@points}%	
	\AMCX@setFormula%
}



	

% === Define the formula for scoring the parsed input ===
\def\AMCX@setFormula{%
	\setcounter{AMCX@garbCount}{0}
	\loop
		\scoring{default.INT\theAMCX@garbCount=0}%
		\scoring{default.FRC\theAMCX@garbCount=0}%
		\scoring{default.POW\theAMCX@garbCount=0}%
		\stepcounter{AMCX@garbCount}%
		\ifnum\theAMCX@garbCount<10\relax%
	\repeat
%
	\scoring{default.SGN=1}%
	\scoring{default.SGX=1}%
%	
%	
	\scoring{formula=(abs(ANS-(SGN)*(%
		   INT0*10**0+FRC0/10**1%
		  +INT1*10**1+FRC1/10**2%
		  +INT2*10**2+FRC2/10**3%
		  +INT3*10**3+FRC3/10**4%
		  +INT4*10**4+FRC4/10**5%
		  +INT5*10**5+FRC5/10**6%
		  +INT6*10**6+FRC6/10**7%
		  +INT7*10**7+FRC7/10**8%
		  +INT8*10**8+FRC8/10**9%
		  +INT9*10**9+FRC9/10**10%
		)*10**(SGX*(%
	       POW0*10**0%
	      +POW1*10**1%
	      +POW2*10**2%
	      +POW3*10**3%
	      +POW4*10**4%
	      +POW5*10**5%
	      +POW6*10**6%
	      +POW7*10**7%
	      +POW8*10**8%
			)))<=DELTA?PTS:0)}
}

\newcommand{\questExemple}{\QuestionIndicative \AMC@correctrue }


\newcommand{\virg}[1]{%
	\def\AMC@trashDot{.}
	\expandafter\@tfor\expandafter\tmp\expandafter:\expandafter=#1\do{\ifx\tmp\AMC@trashDot,\else\tmp\fi}%
}


% === Generate random number in a given interval (normal format) ===
\def\interval #1 [#2,#3].#4{%
	\def\bound@min{#2}%
	\def\bound@max{#3}%
	\FPeval{#1}{trunc((\bound@min)+((\bound@max)-(\bound@min))*random,#4)}%
	\expandafter\expandafter\expandafter\def\expandafter\csname #1disp\endcsname{\expandafter\virg\csname#1\endcsname}		
}

% === Generate random number in a given scientific notation range ===
\def\intervalSci #1 [#2E#3,#4E#5].#6{%
	\FPeval{\bound@min}{(#2)*10^(#3)}
	\FPeval{\bound@max}{(#4)*10^(#5)}
	\FPeval{\random@number}{(\bound@min) + ((\bound@max)-(\bound@min))*random}
	%
	\AMCX@initialize{display=(1.#6)E(1)}%
	\expandafter\AMCX@buildInputNumber\expandafter{\random@number}%
	\AMCX@toSciForm%
	\expandafter\expandafter\expandafter\def\expandafter\csname #1disp\endcsname{\ensuremath{%
		\AMCX@SCIsgn{}%
		\AMCX@SCIint{},%
		\AMCX@SCIfrc{}\cdot10^{%
		\AMCX@SCIsgx{}%
		\AMCX@SCIpow{}}}}%
	\FPeval{#1}{(\AMCX@SCIsgn\AMCX@SCIint.\AMCX@SCIfrc)*10^((\AMCX@SCIsgx\AMCX@SCIpow))}
}

%\newcommand{\displayNumber}[1]{%
%	\AMCX@initialize{}%
%	\expandafter\AMCX@buildInputNumber\expandafter{#1}%
%	\AMCX@toNormForm%
%	\AMCX@toSciForm%
%	\AMCX@NORMsgn{}\AMCX@NORMint{}.\AMCX@NORMfrc{}\\
%	\AMCX@SCIsgn{}\AMCX@SCIint{}.\AMCX@SCIfrc{}$\cdot10^{\AMCX@SCIsgx{}\AMCX@SCIpow{}}$
%}