VB icon

Invert Signed Numerical

Email
Submitted on: 8/11/2018 4:37:45 PM
By: Nicholas Forystek  
Level: Intermediate
User Rating: Unrated
Compatibility: VB 6.0
Views: 1623
author picture
 
     This is a invert function that, I am unsure is 100% accurate, but appears for the lower memory definitions of integer as such that it is inverting, however the whole basis container is considerably the incremental signed value of the unsigned input.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Invert Signed Numerical
' Description:This is a invert function that, I am unsure is 100% accurate, but appears for the lower memory definitions of integer as such that it is inverting, however the whole basis container is considerably the incremental signed value of the unsigned input.
' By: Nicholas Forystek
'**************************************

Public Function Invert(ByVal Value As Variant, Optional ByVal Whole As Variant = Empty) As Variant ' _
Inverts the Value based ona Whole, unspecified integers invert in 32767 and longs in 2147483647, and, Invert(25, 100)=75
If TypeName(Whole) = "Empty" Then
Select Case TypeName(Value)
Case "Byte"
Value = -1 - CDbl(CDbl(-CDbl(125) + -(CDbl(Value) - 1) + CDbl(CDbl(125) * CDbl(2))))
Case "Integer", "Boolean"
Value = -1 - CDbl(CDbl(-CDbl(32677) + -(CDbl(Value) - 1) + CDbl(CDbl(32677) * CDbl(2))))
Case "Long", "Single"
Value = -1 - CDbl(CDbl(-CDbl(1073741824) + -(CDbl(Value) - 1) + CDbl(CDbl(1073741824) * CDbl(2))))
Case "Double", "Currency"
Value = -1 - CDbl(CDbl(-CDbl(125) + -(CDbl(Value) - 1) + CDbl(CDbl(125) * CDbl(2147483645))))
Case Else
Value = -125 - CDbl(CDbl(-CDbl(32765) + -(CDbl(Value) - 125) + CDbl(CDbl(32765) * CDbl(2147483645))))
End Select
Else
Value = CDbl(-CDbl(Whole) + -CDbl(Value)) + CDbl(CDbl(Whole) * CDbl(2))
End If
Invert = Value
End Function


Other 22 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.