Click here to Skip to main content
15,886,518 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Chris Quinn16-Sep-14 21:42
Chris Quinn16-Sep-14 21:42 
AnswerRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Richard MacCutchan16-Sep-14 21:44
mveRichard MacCutchan16-Sep-14 21:44 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
dilkonika17-Sep-14 4:19
dilkonika17-Sep-14 4:19 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Dave Kreskowiak17-Sep-14 4:58
mveDave Kreskowiak17-Sep-14 4:58 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
dilkonika17-Sep-14 5:02
dilkonika17-Sep-14 5:02 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Dave Kreskowiak17-Sep-14 5:08
mveDave Kreskowiak17-Sep-14 5:08 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Eddy Vluggen17-Sep-14 5:13
professionalEddy Vluggen17-Sep-14 5:13 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Eddy Vluggen17-Sep-14 7:27
professionalEddy Vluggen17-Sep-14 7:27 
Let's try that again. We have multiple ways of displaying a number.

MSDN wrote:
The Decimal[^] value type represents decimal numbers ranging from positive 79,228,162,514,264,337,593,543,950,335 to negative 79,228,162,514,264,337,593,543,950,335. The Decimal value type is appropriate for financial calculations that require large numbers of significant integral and fractional digits and no round-off errors. The Decimal type does not eliminate the need for rounding. Rather, it minimizes errors due to rounding. For example, the following code produces a result of 0.9999999999999999999999999999 instead of 1.
VB
Dim dividend As Decimal = Decimal.One
Dim divisor As Decimal = 3
' The following displays 0.9999999999999999999999999999 to the console
Console.WriteLine(dividend/divisor * divisor)
Maps to decimal[^] in SQL Server

MSDN wrote:
The Double[^] value type represents a double-precision 64-bit number with values ranging from negative 1.79769313486232e308 to positive 1.79769313486232e308, as well as positive or negative zero, PositiveInfinity, NegativeInfinity, and not a number (NaN). It is intended to represent values that are extremely large (such as distances between planets or galaxies) or extremely small (the molecular mass of a substance in kilograms) and that often are imprecise (such as the distance from earth to another solar system), The Double type complies with the IEC 60559:1989 (IEEE 754) standard for binary floating-point arithmetic.
That's your float in .NET.

The floating operations are faster than the decimal operations, and, if all is well, integer operations would be even faster. You keep fixing on a formatted value of $2.53 in your wallet. With some creativity you could store those as 253 cents in your database. It is impossible to work with half-a-cent, since they do not exist. No more rounding errors, and the most optimal to work with: a bigint (Int64) to store cents.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Richard MacCutchan17-Sep-14 5:03
mveRichard MacCutchan17-Sep-14 5:03 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
dilkonika17-Sep-14 6:37
dilkonika17-Sep-14 6:37 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Richard MacCutchan17-Sep-14 7:23
mveRichard MacCutchan17-Sep-14 7:23 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
dilkonika17-Sep-14 14:26
dilkonika17-Sep-14 14:26 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Dave Kreskowiak17-Sep-14 17:15
mveDave Kreskowiak17-Sep-14 17:15 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Richard MacCutchan17-Sep-14 20:57
mveRichard MacCutchan17-Sep-14 20:57 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Eddy Vluggen17-Sep-14 7:49
professionalEddy Vluggen17-Sep-14 7:49 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
dilkonika17-Sep-14 8:04
dilkonika17-Sep-14 8:04 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Dave Kreskowiak17-Sep-14 17:18
mveDave Kreskowiak17-Sep-14 17:18 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
dilkonika18-Sep-14 4:39
dilkonika18-Sep-14 4:39 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Dave Kreskowiak18-Sep-14 5:41
mveDave Kreskowiak18-Sep-14 5:41 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
dilkonika18-Sep-14 6:08
dilkonika18-Sep-14 6:08 
QuestionRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Eddy Vluggen18-Sep-14 7:27
professionalEddy Vluggen18-Sep-14 7:27 
AnswerRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
dilkonika18-Sep-14 13:18
dilkonika18-Sep-14 13:18 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Dave Kreskowiak18-Sep-14 14:23
mveDave Kreskowiak18-Sep-14 14:23 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
dilkonika18-Sep-14 14:50
dilkonika18-Sep-14 14:50 
GeneralRe: Vb.net + SQL Server : Speed difference using float vs Decimal Pin
Dave Kreskowiak18-Sep-14 15:18
mveDave Kreskowiak18-Sep-14 15:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.