Jump to content

decimal

- - - - -

  • Please log in to reply
2 replies to this topic

#1
irancplusplus

irancplusplus

    Learning Programmer

  • Members
  • PipPipPip
  • 65 posts
hi
I think a decimal number is stored as a fixed point number (not a floating point number). that is, a decimal always has fixed number of digits after ".".
am I correct?
I wrote this ebook! Will you translate it into English for free!?:confused: PM me!

#2
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
It's more than that. Decimal values store exact values whereas floating points are stored as binary fractions, and thus some decimal numbers do not have exact representations and must be approximated. Because of this, decimals have a smaller range than doubles, but higher precision.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#3
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 242 posts

irancplusplus said:

hi
I think a decimal number is stored as a fixed point number (not a floating point number). that is, a decimal always has fixed number of digits after ".".
am I correct?
No. A decimal has a fixed number of digits (20). It doesn't matter where the decimal point is, you only get a total of 20 digits.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users