Sponsors

Go Back   Zune Boards > Zune Discussions > Zune Games > Development Discussions

New Member?


Register Zunecentive FAQ Members List Calendar Search Today's Posts Mark Forums Read

Development Discussions All developers who are coding games may stop by here for any help, suggestions, and everything development related.

Reply
 
LinkBack Thread Tools
Old 07-05-2008, 11:28 PM   #1 (permalink)
Member
 
ShotgunSnipist's Avatar
 
Join Date: May 2008
Location: Colorado
Posts: 651
Reputation: 51
Send a message via AIM to ShotgunSnipist
$zB: 335
Donate
Default Help Me With Volume Control!

So right now I have it changing volume control with:
MediaPlayer.Volume -= .03f;
And It's 'Printing' It with:
String Volume = "Volume: " + MediaPlayer.Volume.ToString();


Nothing is Wrong With the code, but when you adjust the volume it goes into odd decimals. Pressing down then up will give me .9999 instead of 1.

My question is, how could I code this to Not only stop going into decimals but make it 1-20 (in increments of 1) instead of 0 to 1 (in increments of .03).

Thanks.


Another little problem I have,
I have
DateTime.Now.ToString()
Being 'printed' and it is a few hours off. How could I adjust this? (in game, pressing left and right)
__________________
Invisible Text. =P
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



ShotgunSnipist is offline   Reply With Quote
Remove Advertisements Sponsored Links
Advertisement
 
Old 07-06-2008, 12:12 AM   #2 (permalink)
Jr. Member
 
SimReality's Avatar
 
Join Date: May 2008
Location: Seattle, WA
Posts: 398
Reputation: 60
$zB: 341
Donate
Default

Welcome to floating point inaccuracy. On any computer that works in binary you will always see this when doing floating point arithmetic. The only way to solve it is use integers . Something like:

int myVolume = 100;
MediaPlayer.Volume = myVolume / 100f;
string volume = "Volume: " + myVolume + "%";

Then you'll always see an even number displayed as a percentage of the volume. But basically when it comes to floating point math on a computer, you are never guaranteed for it to be exact. That's just how it is.
__________________
Nick Gravelyn
Microsoft MVP - DirectX/XNA

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



SimReality is offline   Reply With Quote
Old 07-06-2008, 09:00 AM   #3 (permalink)
Jr. Member
 
Tiptup300's Avatar
 
Join Date: Apr 2008
Posts: 371
Reputation: 111
$zB: 272
Donate
Default

And for the record .9 repeating == 1



Tiptup300 is offline   Reply With Quote
Old 07-06-2008, 06:23 PM   #4 (permalink)
Member
 
ShotgunSnipist's Avatar
 
Join Date: May 2008
Location: Colorado
Posts: 651
Reputation: 51
Send a message via AIM to ShotgunSnipist
$zB: 335
Donate
Default

Quote:
Originally Posted by SimReality View Post
Welcome to floating point inaccuracy. On any computer that works in binary you will always see this when doing floating point arithmetic. The only way to solve it is use integers . Something like:

int myVolume = 100;
MediaPlayer.Volume = myVolume / 100f;
string volume = "Volume: " + myVolume + "%";

Then you'll always see an even number displayed as a percentage of the volume. But basically when it comes to floating point math on a computer, you are never guaranteed for it to be exact. That's just how it is.
Thanks!
Worked awesome!

Quote:
Originally Posted by Tiptup300 View Post
And for the record .9 repeating == 1
If you did mean to put == (2 of them) there,
Yes I suppose that would work...
But that's a hell of a lot of code because it did it for every increment.
__________________
Invisible Text. =P
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



ShotgunSnipist is offline   Reply With Quote
Old 07-06-2008, 09:08 PM   #5 (permalink)
Jr. Member
 
Tiptup300's Avatar
 
Join Date: Apr 2008
Posts: 371
Reputation: 111
$zB: 272
Donate
Default

No, mathematically speaking, .9 repeating is exactly the same value as 1

1/3 = .3 repeating

.3 repeating * 3 = 1

.3 repeating * 3 also = .9 repeating



Tiptup300 is offline   Reply With Quote
Old 07-06-2008, 10:38 PM   #6 (permalink)
Member
 
ShotgunSnipist's Avatar
 
Join Date: May 2008
Location: Colorado
Posts: 651
Reputation: 51
Send a message via AIM to ShotgunSnipist
$zB: 335
Donate
Default

Quote:
Originally Posted by Tiptup300 View Post
No, mathematically speaking, .9 repeating is exactly the same value as 1

1/3 = .3 repeating

.3 repeating * 3 = 1

.3 repeating * 3 also = .9 repeating
Oh okay. I thought you meant to program into the program to recognize .9999 and make it display 1.
__________________
Invisible Text. =P
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



ShotgunSnipist is offline   Reply With Quote
Old 07-15-2008, 07:27 AM   #7 (permalink)
Zewbie
 
Join Date: Jul 2008
Posts: 2
Reputation: 10
$zB: 2
Donate
Default Is this to create a higher volume

If so I'm SOO interested. I have programming experience. Your help would be apprieciated



acura86 is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -8. The time now is 02:43 AM.

 
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC8
vB Ad Management by =RedTyger=
(C) ZuneBoards 2006-2007