Google Answers Logo
View Question
Q: Computer Programming, C++ 'SIGN' function, 1.d0 ( Answered,   0 Comments )
Subject: Computer Programming, C++ 'SIGN' function, 1.d0
Category: Computers > Programming
Asked by: cping3-ga
List Price: $5.00
Posted: 08 Jul 2004 18:53 PDT
Expires: 07 Aug 2004 18:53 PDT
Question ID: 371633
I am writing a simulation code in MATLAB. I am using a set of formulas
called 'Pacejka 94', they are formulas used to simulate a vehicle

The code I am copying from is 'I believe' C++, but it may be something
else similar. The text I am copying the code from does not

The script in question is:


The real issue I have is with the variable 1.D0 or 1.d0. What does
this stand for? I have a variable named D already, and it may be the
initial value for D, but I still don't know what the 1 and period are
for. Is this a single variable, a dot product, or?

Also, I do not understand the function 'SIGN()'. MATLAB has a SIGN
function but it only operates for a single variable, not a pair (as it
seems to be). Can you explain the SIGN function.

I understand all the other variables in the equation (X1, B6, FZ,
etc), they are just integers.
Subject: Re: Computer Programming, C++ 'SIGN' function, 1.d0
Answered By: hedgie-ga on 08 Jul 2004 20:18 PDT
The D is used instead of E  to express double precision numbers, e.g.
in FORTRAN, as shown here
DATA X /.01/
IF ( X * 100.d0 .NE. 1.0 ) THEN
   PRINT *, 'Many systems print this surprising result. '
   PRINT *, 'And some may print this.'

FORTRAN also has sign with 2 arguments, explained e.g. here
Sign(A, B)

 Sign: INTEGER or REAL function, the exact type being the result of
cross-promoting the types of all the arguments.
Returns `ABS(A)*s', where s is +1 if `B.GE.0', -1 otherwise.

or here 
The function sign in Fortran is called the sign transfer function. It
is a function of two variables, sign(x,y)
If we substitute x = 1 in the sign transfer function, we get the sign of y;

So, it looks like Hans was writing in Fortran

Request for Answer Clarification by cping3-ga on 08 Jul 2004 22:00 PDT
Ok, so the 1.d0 is some kind of precision, and sign() is some kind of
an assignable negative.

So if I understand this correctly:


is roughly equivalent to

(1-(B13*-1)) if X1 is negative
(1-(B13*1)) if X1 is positive

Is this what you see as well? I am very rusty on my Fortran. The
double precision call-out is simply so you can do the math in Fortran
correct? (It won't subtract a double precision from an integer).


Clarification of Answer by hedgie-ga on 09 Jul 2004 08:26 PDT
Basically yes.
You can do calculation with single precision, but it is
recommended and customary to do numerical, nontrivial ones in
double, to get reasonable accuracy.
 "...It won't subtract a double precision from an integer ."
and neither it will subtract single precision (both are floats)
(so double in FORTAN is long float in c) .You need to cast your integer to
suitable float before add/subtract from floats.
 So what your wrote  is basically correct, except for the
type (you got integer) and he got that same number as a double float.

Very simply,  you wrote 1  , which, when cast as single precision number 
is                      1.00000000000
and as double           1.000000000000000000000000000
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy