How to convert string to float?

Ask a Question related to ASP, Design and Development.

  1. #1

    Default How to convert string to float?

    i want to covert a querystring to float number in asp.
    what function should i use?

    i know cint() can convert string to int
    but how about float?


    Jason Chan Guest

  2. Similar Questions and Discussions

    1. #39126 [NEW]: String->float->String conversion behavior
      From: bobson at rpg dot pl Operating system: Linux PHP version: 5CVS-2006-10-11 (snap) PHP Bug Type: Unknown/Other Function...
    2. Convert float value to integer
      l have a simple question ...l want to convert value from float to interger exemple 5.399 convert to 5 or 5.79 convert to 6
    3. help float to string
      try the sprintf print sprint("%.02f", $f); if I'm not rong; -----Original Message----- From: perl@swanmail.com
    4. #25562 [Opn->Bgs]: Float to String to Float conversion error
      ID: 25562 Updated by: helly@php.net Reported By: daseymour at 3hc dot org -Status: Open +Status: ...
    5. #25562 [NEW]: Float to String to Float conversion error
      From: daseymour at 3hc dot org Operating system: and PHP version: 4.3.3 PHP Bug Type: Math related Bug description: Float...
  3. #2

    Default Re: How to convert string to float?

    hi,

    usually you can use the round function.
    As asp deals with the variant type, something tlike that should work

    'querystring : ?id=1&value=10.874
    id=request.querystring("id")
    v=request.querystring("value")
    v=round(v,3)


    "Jason Chan" <no@email.com> a écrit dans le message de
    news:OZlikrpcDHA.856@tk2msftngp13.phx.gbl...
    > i want to covert a querystring to float number in asp.
    > what function should i use?
    >
    > i know cint() can convert string to int
    > but how about float?
    >
    >

    Martin CLAVREUIL Guest

  4. #3

    Default Re: How to convert string to float?

    CDbl() or CSng() will do the trick. Use IsNumeric() to make sure it's
    numeric first.

    Alan

    "Jason Chan" <no@email.com> wrote in message
    news:OZlikrpcDHA.856@tk2msftngp13.phx.gbl...
    > i want to covert a querystring to float number in asp.
    > what function should i use?
    >
    > i know cint() can convert string to int
    > but how about float?
    >
    >

    Alan Guest

  5. #4

    Default Re: How to convert string to float?

    I got it, thanks~
    "Martin CLAVREUIL" <martin.clavreuil@wanadoo.fr> ¦b¶l¥ó news:e9XhoAqcDHA.1884@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
    > hi,
    >
    > usually you can use the round function.
    > As asp deals with the variant type, something tlike that should work
    >
    > 'querystring : ?id=1&value=10.874
    > id=request.querystring("id")
    > v=request.querystring("value")
    > v=round(v,3)
    >
    >
    > "Jason Chan" <no@email.com> a écrit dans le message de
    > news:OZlikrpcDHA.856@tk2msftngp13.phx.gbl...
    > > i want to covert a querystring to float number in asp.
    > > what function should i use?
    > >
    > > i know cint() can convert string to int
    > > but how about float?
    > >
    > >
    >
    >

    Jason Chan Guest

  6. #5

    Default Re: How to convert string to float?

    Thanks for answering.
    "Alan" <XalanX.XhowardX@XparadiseX.XnetX.XnzX> ¦b¶l¥ó news:ep0OJhrcDHA.2672@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
    > CDbl() or CSng() will do the trick. Use IsNumeric() to make sure it's
    > numeric first.
    >
    > Alan
    >
    > "Jason Chan" <no@email.com> wrote in message
    > news:OZlikrpcDHA.856@tk2msftngp13.phx.gbl...
    > > i want to covert a querystring to float number in asp.
    > > what function should i use?
    > >
    > > i know cint() can convert string to int
    > > but how about float?
    > >
    > >
    >
    >

    Jason Chan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139