×
Namespaces

Variants
Actions

Create a pseudo-random value by using no-repeatable time as the seed

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): E90
Compatibility
Platform(s): S60 3rd,3rd FP1,3rd Fp2
Platform Security
Capabilities: )
Article
Keywords: keywords= TTime::HomeTime,Math::Rand.
Created: lming (01 Nov 2008)
Last edited: hamishwillee (24 Jun 2011)

Overview

This snippet demonstrates how to create a pseudo-random value by using no-repeatable time as the seed. This snippet can be self-signed

Use Case

create a pseudo-random value by using no-repeatable time as the seed.

Source file

//necessary library
LIBRARY hash.lib
LIBRARY euser.lib
//necessary header file
#include <hash.h>
#include <e32std.h>
 
TTime currentTime;
//get current time
currentTime.HomeTime();
 
//seed it the 64 bit value of current time
TInt64 seed = currentTime.Int64();
 
//randomValue contains the produced pseudo-random value
TInt randomValue = Math::Rand(seed);

Postconditions

randomValue contains the produced pseudo-random value.

This page was last modified on 24 June 2011, at 11:38.
42 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×