×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Exclamation Point attached to variable name

Exclamation Point attached to variable name

Exclamation Point attached to variable name

(OP)
I saw something in someone else's code--an exclamation point at the end of a variable name. I was unfamiliar with the usage, looked it up, read that the exclamation point is used to specify a variable as precision Single.

Usage: "dummy!"  will make the variable "dummy" a Single precision variable.

Why would someone use the exclamation point? Why not just make all floating point (real) variables Double precision?

RE: Exclamation Point attached to variable name

The main reason would be either for storage space or for compatibility with some legacy or embedded application.  When Excel was first created, most microprocessors could not do 64-bit floating point, and single-precision was the norm.

btw # evokes double.  However, the characters are not parsed by VBA.  You declare type using Dim.  The appended characters are for the programmer to keep track of types.

TTFN

FAQ731-376: Eng-Tips.com Forum Policies

RE: Exclamation Point attached to variable name

Those characters are in fact parsed by vba.

 

=====================================
Eng-tips forums: The best place on the web for engineering discussions.

RE: Exclamation Point attached to variable name

Try this

CODE

Sub mytest()
 Dummy1! = (Application.WorksheetFunction.Pi())
 Dummy2# = (Application.WorksheetFunction.Pi())
 Dummy1! = Dummy1! * 1E+17
 Dummy2# = Dummy2# * 1E+17
 Debug.Print Dummy1! - Dummy2#
End Sub
The printed difference is
 157376256  

=====================================
Eng-tips forums: The best place on the web for engineering discussions.

RE: Exclamation Point attached to variable name

Quote:

Why not just make all floating point (real) variables Double precision?
That's what I do and I think what most people do.

But, if you have a large program computationally intensive program with lots of variables, I believe you can save memory and speed execution by using single vs double if you don't need the extra accuracy.  That was probably more important in the old days.  Hard to imagine there are many practical cases when it makes a big difference anymore.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.

RE: Exclamation Point attached to variable name

Also as IRStuff says - it may help compatibility or comparability with older applications that used single precision.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.

RE: Exclamation Point attached to variable name

(OP)
Thanks for the exclamation, and the reminder that not so long ago, we really didn't have that much space in RAM or hard drive to use, and sometimes had to be careful with memory allocation.

RE: Exclamation Point attached to variable name

(OP)
that's funny, 'exclamation' on the brain. I meant "Thanks for the explanation,"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

White Paper - How ESI is Helping Move New Medical Device Product to Market Quicker & More Cost Effic
Early Supplier Involvement has long been a strategy employed by manufacturers to produce innovative products. Now, it almost seems like a necessity. Because decisions made in the design phase can positively affect product quality and costs, this can help add value to OEM bottom lines. This white paper will discuss many facets of ESI, including why it’s so valuable today, what challenges limit the benefits of ESI, how cost is impacted, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close