accurate conversion (currency and it cents with fmod)weird output when printing data of custom string (c++ newbie)recursive trailing return types visual studio 2010Difference between c++ functions 'remainder' and 'fmod'?Searchable Enum-like object with string and int conversionC++: perfect transparent wrapping of base types into a class?C++ , A code to get an amount of money to convert into quarters, dimes , nickels, penniesStack returning copy because of inheritance?How to stop C++ from automatically converting double to int?Converting dollars to cents in c++Currency format in C++
How do we say "within a kilometer radius spherically"?
I've been given a project I can't complete, what should I do?
Use 1 9 6 2 in this order to make 75
How to write a convincing religious myth?
Why are MBA programs closing in the United States?
Why did the World Bank set the global poverty line at $1.90?
Why do some devices use electrolytic capacitors instead of ceramics for small value components?
How durable are silver inlays on a blade?
Should I put programming books I wrote a few years ago on my resume?
Analogy between an unknown in an argument, and a contradiction in the principle of explosion
Do you need to let the DM know when you are multiclassing?
Zig-zag function - coded solution
What should I discuss with my DM prior to my first game?
Make Gimbap cutter
Who is "He that flies" in Lord of the Rings?
Diatonic chords of a pentatonic vs blues scale?
What would be the way to say "just saying" in German? (Not the literal translation)
Why ambiguous grammars are bad?
Assigning function to function pointer, const argument correctness?
Increase speed altering column on large table to NON NULL
Proving that a Russian cryptographic standard is too structured
Do empty drive bays need to be filled?
Does the new finding on "reversing a quantum jump mid-flight" rule out any interpretations of QM?
Could a person damage a jet airliner - from the outside - with their bare hands?
accurate conversion (currency and it cents with fmod)
weird output when printing data of custom string (c++ newbie)recursive trailing return types visual studio 2010Difference between c++ functions 'remainder' and 'fmod'?Searchable Enum-like object with string and int conversionC++: perfect transparent wrapping of base types into a class?C++ , A code to get an amount of money to convert into quarters, dimes , nickels, penniesStack returning copy because of inheritance?How to stop C++ from automatically converting double to int?Converting dollars to cents in c++Currency format in C++
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
If I convert 5 USD to Euro, it should be 4.45 or 4 euro and 45 cent
the problem is that I get 4 and 0.55 instead of 0.45 or is there a way to get 45 cent??
enter code here
int main()
double usd = 0, euro = 0;
double fixeuro = 0.89;
cout << "Please add amount to convert itn";
cin >> usd;
int conv = usd * fixeuro;
cout << conv << "n";
cout << fmod(usd,fixeuro);
return 0;
c++11
add a comment |
If I convert 5 USD to Euro, it should be 4.45 or 4 euro and 45 cent
the problem is that I get 4 and 0.55 instead of 0.45 or is there a way to get 45 cent??
enter code here
int main()
double usd = 0, euro = 0;
double fixeuro = 0.89;
cout << "Please add amount to convert itn";
cin >> usd;
int conv = usd * fixeuro;
cout << conv << "n";
cout << fmod(usd,fixeuro);
return 0;
c++11
Did you already check if theusd
value has been read correctly? (cout << usd
)
– Martin Rosenau
Mar 24 at 21:48
sorry I meant 4 instead of 5 (already corrected it)
– adam
Mar 24 at 21:51
I am really sorry I have just corrected every thing
– adam
Mar 24 at 21:58
add a comment |
If I convert 5 USD to Euro, it should be 4.45 or 4 euro and 45 cent
the problem is that I get 4 and 0.55 instead of 0.45 or is there a way to get 45 cent??
enter code here
int main()
double usd = 0, euro = 0;
double fixeuro = 0.89;
cout << "Please add amount to convert itn";
cin >> usd;
int conv = usd * fixeuro;
cout << conv << "n";
cout << fmod(usd,fixeuro);
return 0;
c++11
If I convert 5 USD to Euro, it should be 4.45 or 4 euro and 45 cent
the problem is that I get 4 and 0.55 instead of 0.45 or is there a way to get 45 cent??
enter code here
int main()
double usd = 0, euro = 0;
double fixeuro = 0.89;
cout << "Please add amount to convert itn";
cin >> usd;
int conv = usd * fixeuro;
cout << conv << "n";
cout << fmod(usd,fixeuro);
return 0;
c++11
c++11
edited Mar 24 at 21:57
adam
asked Mar 24 at 21:43
adamadam
12
12
Did you already check if theusd
value has been read correctly? (cout << usd
)
– Martin Rosenau
Mar 24 at 21:48
sorry I meant 4 instead of 5 (already corrected it)
– adam
Mar 24 at 21:51
I am really sorry I have just corrected every thing
– adam
Mar 24 at 21:58
add a comment |
Did you already check if theusd
value has been read correctly? (cout << usd
)
– Martin Rosenau
Mar 24 at 21:48
sorry I meant 4 instead of 5 (already corrected it)
– adam
Mar 24 at 21:51
I am really sorry I have just corrected every thing
– adam
Mar 24 at 21:58
Did you already check if the
usd
value has been read correctly? (cout << usd
)– Martin Rosenau
Mar 24 at 21:48
Did you already check if the
usd
value has been read correctly? (cout << usd
)– Martin Rosenau
Mar 24 at 21:48
sorry I meant 4 instead of 5 (already corrected it)
– adam
Mar 24 at 21:51
sorry I meant 4 instead of 5 (already corrected it)
– adam
Mar 24 at 21:51
I am really sorry I have just corrected every thing
– adam
Mar 24 at 21:58
I am really sorry I have just corrected every thing
– adam
Mar 24 at 21:58
add a comment |
1 Answer
1
active
oldest
votes
The way to get the correct amount is double conv = usd * fixeuro;
Then if you want to get just the euros, that's int euros = conv;
and just the eurocents is int eurocents = 100 * (conv - euros);
Or, if you want, you can use 100 * fmod(conv, 1.0)
.
fmod(usd,fixeuro)
doesn't appear to have any obvious meaning. It's what you are left with when you have 5 USD and start throwing away exactly 89 cents at a time until you have less than 89 cents. 89 US cents do not correspond to any interesting amount in euros, and US cents are not eurocents, so it isn't quite clear what you get from this.
Thanks that was the solution , my goal using fmod is same as modulo, I thought I would get whats left after comma
– adam
Mar 24 at 22:20
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328860%2faccurate-conversion-currency-and-it-cents-with-fmod%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The way to get the correct amount is double conv = usd * fixeuro;
Then if you want to get just the euros, that's int euros = conv;
and just the eurocents is int eurocents = 100 * (conv - euros);
Or, if you want, you can use 100 * fmod(conv, 1.0)
.
fmod(usd,fixeuro)
doesn't appear to have any obvious meaning. It's what you are left with when you have 5 USD and start throwing away exactly 89 cents at a time until you have less than 89 cents. 89 US cents do not correspond to any interesting amount in euros, and US cents are not eurocents, so it isn't quite clear what you get from this.
Thanks that was the solution , my goal using fmod is same as modulo, I thought I would get whats left after comma
– adam
Mar 24 at 22:20
add a comment |
The way to get the correct amount is double conv = usd * fixeuro;
Then if you want to get just the euros, that's int euros = conv;
and just the eurocents is int eurocents = 100 * (conv - euros);
Or, if you want, you can use 100 * fmod(conv, 1.0)
.
fmod(usd,fixeuro)
doesn't appear to have any obvious meaning. It's what you are left with when you have 5 USD and start throwing away exactly 89 cents at a time until you have less than 89 cents. 89 US cents do not correspond to any interesting amount in euros, and US cents are not eurocents, so it isn't quite clear what you get from this.
Thanks that was the solution , my goal using fmod is same as modulo, I thought I would get whats left after comma
– adam
Mar 24 at 22:20
add a comment |
The way to get the correct amount is double conv = usd * fixeuro;
Then if you want to get just the euros, that's int euros = conv;
and just the eurocents is int eurocents = 100 * (conv - euros);
Or, if you want, you can use 100 * fmod(conv, 1.0)
.
fmod(usd,fixeuro)
doesn't appear to have any obvious meaning. It's what you are left with when you have 5 USD and start throwing away exactly 89 cents at a time until you have less than 89 cents. 89 US cents do not correspond to any interesting amount in euros, and US cents are not eurocents, so it isn't quite clear what you get from this.
The way to get the correct amount is double conv = usd * fixeuro;
Then if you want to get just the euros, that's int euros = conv;
and just the eurocents is int eurocents = 100 * (conv - euros);
Or, if you want, you can use 100 * fmod(conv, 1.0)
.
fmod(usd,fixeuro)
doesn't appear to have any obvious meaning. It's what you are left with when you have 5 USD and start throwing away exactly 89 cents at a time until you have less than 89 cents. 89 US cents do not correspond to any interesting amount in euros, and US cents are not eurocents, so it isn't quite clear what you get from this.
answered Mar 24 at 22:07


n.m.n.m.
75.1k887173
75.1k887173
Thanks that was the solution , my goal using fmod is same as modulo, I thought I would get whats left after comma
– adam
Mar 24 at 22:20
add a comment |
Thanks that was the solution , my goal using fmod is same as modulo, I thought I would get whats left after comma
– adam
Mar 24 at 22:20
Thanks that was the solution , my goal using fmod is same as modulo, I thought I would get whats left after comma
– adam
Mar 24 at 22:20
Thanks that was the solution , my goal using fmod is same as modulo, I thought I would get whats left after comma
– adam
Mar 24 at 22:20
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328860%2faccurate-conversion-currency-and-it-cents-with-fmod%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you already check if the
usd
value has been read correctly? (cout << usd
)– Martin Rosenau
Mar 24 at 21:48
sorry I meant 4 instead of 5 (already corrected it)
– adam
Mar 24 at 21:51
I am really sorry I have just corrected every thing
– adam
Mar 24 at 21:58