Click here to Skip to main content
16,019,740 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Character set Pin
CPallini13-Sep-24 1:34
mveCPallini13-Sep-24 1:34 
GeneralRe: Character set Pin
trønderen14-Sep-24 6:48
trønderen14-Sep-24 6:48 
GeneralRe: Character set Pin
Calin Negru14-Sep-24 9:18
Calin Negru14-Sep-24 9:18 
GeneralRe: Character set Pin
k505414-Sep-24 10:15
mvek505414-Sep-24 10:15 
GeneralRe: Character set Pin
markkuk14-Sep-24 11:15
markkuk14-Sep-24 11:15 
QuestionREMOVED Pin
jana_hus7-Sep-24 7:12
jana_hus7-Sep-24 7:12 
AnswerRe: Addendum how to build real time events in Qt? Pin
Richard MacCutchan7-Sep-24 21:29
mveRichard MacCutchan7-Sep-24 21:29 
QuestionLooking for opinions on currency handling.... Pin
Jeremy Falcon2-Sep-24 8:20
professionalJeremy Falcon2-Sep-24 8:20 
As I'm sure we all know, there are basically three ways to handle currency values in code.

1) Can store the value as cents in an integer. So, $100.00 would be 10,000. Pro: You don't have to worry about floating point precision issues. Con: Harder to mentally glance at without converting it in your head. Con: Depending on size of integer may significantly reduce available numbers to be stored.

2) Can use a float with a large enough precision. Pro: Easy to read. Con: Rounding issues, precision issues, etc.

3) Can use a struct with a dollars and cents. Pro: Same benefit as integer with no number loss. Pro: Easy to read mentally. Con: Have to convert back and forth or go out of the way for calculations.

Historically, I've always gone with either 1 or 2 with just enough precision to get by. However, I'm working on a financial app and figured... why not live a little. Laugh | :laugh:

So, I'm thinking about using 128-bit ints and shift its "offset" by 6, so I can store up to 6 decimal places in the int. For a signed value, this would effectively max me out at ~170 nonillion (170,141,183,460,469,231,731,687,303,715,884.105727). Now, last I checked there's not that much money in the world. Laugh | :laugh: But, this will be the only app running on a dedicated machine and using 1GB of RAM is completely ok. So, it's got me thinking...

Here's the question... any of y'all ever use 128-bit ints and did you find them to be incredibly slow compared to 64-bit or is the speed acceptable?
Jeremy Falcon


modified 2-Sep-24 14:37pm.

GeneralRe: Looking for opinions on currency handling.... Pin
k50542-Sep-24 11:16
mvek50542-Sep-24 11:16 
GeneralRe: Looking for opinions on currency handling.... Pin
Jeremy Falcon2-Sep-24 11:35
professionalJeremy Falcon2-Sep-24 11:35 
GeneralRe: Looking for opinions on currency handling.... Pin
Richard Andrew x642-Sep-24 13:49
professionalRichard Andrew x642-Sep-24 13:49 
GeneralRe: Looking for opinions on currency handling.... Pin
Jeremy Falcon2-Sep-24 13:56
professionalJeremy Falcon2-Sep-24 13:56 
GeneralRe: Looking for opinions on currency handling.... Pin
Richard Andrew x642-Sep-24 14:26
professionalRichard Andrew x642-Sep-24 14:26 
GeneralRe: Looking for opinions on currency handling.... Pin
Jeremy Falcon2-Sep-24 15:33
professionalJeremy Falcon2-Sep-24 15:33 
AnswerRe: Looking for opinions on currency handling.... Pin
CPallini2-Sep-24 20:05
mveCPallini2-Sep-24 20:05 
GeneralRe: Looking for opinions on currency handling.... Pin
Jeremy Falcon3-Sep-24 2:48
professionalJeremy Falcon3-Sep-24 2:48 
GeneralRe: Looking for opinions on currency handling.... Pin
CPallini3-Sep-24 3:07
mveCPallini3-Sep-24 3:07 
GeneralRe: Looking for opinions on currency handling.... Pin
Jeremy Falcon3-Sep-24 3:23
professionalJeremy Falcon3-Sep-24 3:23 
GeneralRe: Looking for opinions on currency handling.... Pin
Mircea Neacsu3-Sep-24 15:45
Mircea Neacsu3-Sep-24 15:45 
GeneralRe: Looking for opinions on currency handling.... Pin
Jeremy Falcon3-Sep-24 15:50
professionalJeremy Falcon3-Sep-24 15:50 
GeneralRe: Looking for opinions on currency handling.... Pin
Jeremy Falcon3-Sep-24 15:53
professionalJeremy Falcon3-Sep-24 15:53 
GeneralRe: Looking for opinions on currency handling.... Pin
Mircea Neacsu3-Sep-24 16:07
Mircea Neacsu3-Sep-24 16:07 
GeneralRe: Looking for opinions on currency handling.... Pin
Jeremy Falcon3-Sep-24 17:31
professionalJeremy Falcon3-Sep-24 17:31 
QuestionADDENDUM How to display full 4 binary bits - after QString "number" option converts string to int. including hexadecimal strings. Pin
jana_hus30-Aug-24 7:39
jana_hus30-Aug-24 7:39 
QuestionRe: How to display full 4 binary bits - after QString "number" option converts string to int. Pin
Richard MacCutchan30-Aug-24 8:05
mveRichard MacCutchan30-Aug-24 8:05 

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.