473,473 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to convert a float to a string ??

Hi,

I want to know is there any function in JS the same as "sprintf" in C
language?

Thanks a lot !

Jul 23 '05 #1
4 30795
<su************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I want to know is there any function in JS the same as "sprintf" in C
language?


JS 1.5 has Number.toFixed() and Number.toExponential()
Jul 23 '05 #2


su************@gmail.com wrote:
I want to know is there any function in JS the same as "sprintf" in C
language?


You can use
number.toString()
to get a string representation or
number.toString(16)
to get a hexadecimal string representation of a number value.
In newer JavaScript implementations there are also further functions such as
numer.toFixed(2)
or
number.toExponential(2)
See the JavaScript documentation here:
<http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference>

<http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Number>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3
su************@gmail.com wrote:
I want to know is there any function in JS the same as "sprintf" in C
language?


This has been asked (for) before, therefore the beginning of an approach
of an ECMAScript compliant s?printf(3) implementation can be found here:

<http://pointedears.de/scripts/string.js>, format()

Comments targeting the script code are welcome.
PointedEars
Jul 23 '05 #4
su************@gmail.com wrote:
I want to know is there any function in JS the same as "sprintf" in C
language?


This has been asked (for) before, therefore the beginning of an approach
of an ECMAScript compliant s?printf(3) implementation can be found here:

<http://pointedears.de/scripts/string.js>, format()

Comments targeting the script code are welcome. See

<http://pointedears.de/scripts/test/string>

for a test case.
PointedEars
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
4
by: STom | last post by:
How do you convert a string in C# to decimal? STom
15
by: Yifan | last post by:
Hi Does anybody know how to convert System::String* to char*? I searched the System::String class members and did not find any. Thanks Yifan
4
by: Pixie Songbook | last post by:
Hi, I'm trying to write a program using the Dev C++ 4.9.9.2 compiler that takes input numbers from a word document, sums them together, and then gives me a result. It should be easy as the book I...
3
by: priyanka | last post by:
Hi there, I want to convert a String into integer. I get the string from a file using : string argNum; getline(inputStream,argNum); I now need to convert argNum into integer.
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
7
by: shellon | last post by:
Hi all: I want to convert the float number to sortable integer, like the function float2rawInt() in java, but I don't know the internal expression of float, appreciate your help!
2
by: lisasahu | last post by:
how to convert float to string like there is atof atoi and itoa but is ther any method to convert float to string
5
by: sidhuasp | last post by:
Hi could anyone please tell me how to convert float value in my database ti HOUR/MIN format for my timesheet requirement. i have to do it in sql-reporting services
3
by: audrey29 | last post by:
How do i convert my string to float?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.